diff --git a/BUGS b/BUGS index 0f295ceff..d7d650221 100644 --- a/BUGS +++ b/BUGS @@ -15,3 +15,7 @@ Moving in and out of structures is very buggy. Some objects which are not structures seem to be getting non-solid bounding boxes when they are not structures. It seems that entities inside a structure all end up with being treated as if their bounding boxes were not solid. + +I suspect there may be something wrong with the _num_coerce functions +in python interface code. Some of them do not increment references before +returning. diff --git a/ChangeLog b/ChangeLog index d278e0ab4..44f72ad5c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,35 @@ +2001-04-14 Al Riddoch + + * 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. + 2001-04-12 Al Riddoch * common/BaseEntity.*: Changed addToObject to take reference diff --git a/TODO b/TODO index 8ee7701eb..83d4faf91 100644 --- a/TODO +++ b/TODO @@ -4,7 +4,11 @@ Definitly for Acorn 0.4: Sort out collision detection wrt moving alongside an object in close proximity, and add CD for two moving objects. Basically we need sliding. - along an object. + along an object. This can be done by zeroing the velocity along + the axis perpendicular to the collision. Obviously we need to add + a mechanism for establishing which axis is perpendicular to the collision. + This now works, but the direction the moving entity is facing needs to be + modified. Sort out collision prediction between two moving entities. Current problem is that it is not possible to tell when movement started, and thus get @@ -15,19 +19,11 @@ Definitly for Acorn 0.4: Fully implement stackable objects. Use combine operation to deal with making more than one object into one. - Replace - o = new Operation(); *o = Operation::Instantiate(); - with - o = new Opertion(Operation::Instantiate()); - cos it is about twice as quick. - - Move virtual destructors and other functions into .cpp files. - - Get rid of deleted attribute. - Provisional for Acorn 0.4: - Implement accelerated Atlas Objects API. MAYBE: POSTPONED FROM 0.3 + Implement accelerated Atlas Objects API. MAYBE: + POSTPONED FROM 0.3 + POSTPONED FROM 0.4 Required for werewolf: @@ -38,9 +34,6 @@ Required for werewolf: Possible ideas: - Try out optimisations such as -funroll_loops -fstrict_aliasing -ffast_math - -mx86. Consider a custom python interpreter build. - Add fully featured database persistance. Persistance system is naive right now. It does not take account of that diff --git a/aiclient/ClientAccount.cpp b/aiclient/ClientAccount.cpp index 9a5dc4bc1..1e07721ed 100644 --- a/aiclient/ClientAccount.cpp +++ b/aiclient/ClientAccount.cpp @@ -1,11 +1,13 @@ // This file may be redistributed and modified only under the terms of // the GNU Lesser General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include #include "ClientAccount.h" +using Atlas::Message::Object; + ClientAccount::ClientAccount(const string & name, ClientConnection & con) : connection(con) { diff --git a/aiclient/ClientAccount.h b/aiclient/ClientAccount.h index 594776cba..e1cc487a9 100644 --- a/aiclient/ClientAccount.h +++ b/aiclient/ClientAccount.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU Lesser General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef CLIENT_ACCOUNT_H #define CLIENT_ACCOUNT_H diff --git a/aiclient/ClientConnection.cpp b/aiclient/ClientConnection.cpp index fbba0ba5a..401ec8da1 100644 --- a/aiclient/ClientConnection.cpp +++ b/aiclient/ClientConnection.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU Lesser General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include #include diff --git a/aiclient/ClientConnection.h b/aiclient/ClientConnection.h index 55bc99f9e..e755d29c0 100644 --- a/aiclient/ClientConnection.h +++ b/aiclient/ClientConnection.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU Lesser General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef CLIENT_CONNECTION_H #define CLIENT_CONNECTION_H @@ -77,4 +77,4 @@ class ClientConnection : public Atlas::Objects::Decoder { void loop(); }; -#endif /* CLIENT_CONNECTION_H */ +#endif // CLIENT_CONNECTION_H diff --git a/aiclient/Makefile.am b/aiclient/Makefile.am index 2c5c0166f..bac2e4790 100644 --- a/aiclient/Makefile.am +++ b/aiclient/Makefile.am @@ -15,7 +15,7 @@ cyphesisc_LDFLAGS = -Wl,-export-dynamic else -cyphesisc_LDADD = ../physics/libphysics.a ../rulesets/libscriptpython.a ../rulesets/librulesetmind.a ../rulesets/librulesetbase.a ../rulesets/libscriptpython.a ../rulesets/MemMap.o ../modules/libmodules.a ../common/libcommon.a ../server/OOG_Thing.o +cyphesisc_LDADD = ../physics/libphysics.a ../rulesets/libscriptpython.a ../server/WorldRouter.o ../server/OOG_Thing.o ../rulesets/librulesetmind.a ../rulesets/librulesetentity.a ../rulesets/librulesetbase.a ../rulesets/libscriptpython.a ../modules/libmodules.a ../common/libcommon.a LIBS = -lAtlasObjects -lAtlasObjectsOperation -lAtlasObjectsEntity -lAtlasNet -lAtlas -lAtlasCodecs -lAtlasMessage -lAtlas -lpython1.5 -ldl -lm -lpthread -lvarconf -lsigc -ldb_cxx # -lefence diff --git a/aiclient/client.cpp b/aiclient/client.cpp index 7babd6979..500e6382b 100644 --- a/aiclient/client.cpp +++ b/aiclient/client.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU Lesser General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include #include diff --git a/aiclient/client.h b/aiclient/client.h index 7475d5135..427953e9f 100644 --- a/aiclient/client.h +++ b/aiclient/client.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU Lesser General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef CLIENT_H #define CLIENT_H @@ -10,4 +10,4 @@ extern int exit_flag; extern list rulesets; -#endif /* CLIENT_H */ +#endif // CLIENT_H diff --git a/common/BaseEntity.cpp b/common/BaseEntity.cpp index bbcff981c..9db7ba54f 100644 --- a/common/BaseEntity.cpp +++ b/common/BaseEntity.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -21,40 +21,18 @@ static const bool debug_flag = false; -BaseEntity::BaseEntity() : seq(0), deleted(false), inGame(false), - omnipresent(false), world(NULL) { +using Atlas::Message::Object; + +BaseEntity::BaseEntity() : seq(0), inGame(false) +{ +} + +BaseEntity::~BaseEntity() +{ } void BaseEntity::destroy() { - if (deleted == true) { - return; - } - list_t::const_iterator I; - for(I = contains.begin(); I != contains.end(); I++) { - BaseEntity * obj = *I; - if (obj->deleted == false) { - obj->location.ref = location.ref; - obj->location.coords = location.coords + obj->location.coords; - } - } - if (location) { - location.ref->contains.remove(this); - } -} - -Vector3D BaseEntity::getXyz() const -{ - //Location l=location; - if (!location) { - static Vector3D ret(0.0,0.0,0.0); - return ret; - } - if (location.ref) { - return location.coords+location.ref->getXyz(); - } else { - return location.coords; - } } Object BaseEntity::asObject() const @@ -76,6 +54,7 @@ void BaseEntity::addToObject(Object & obj) const omap["id"] = fullid; } omap["seq"] = seq; +#if 0 Object::ListType contlist; list_t::const_iterator I; for(I = contains.begin(); I != contains.end(); I++) { @@ -84,6 +63,7 @@ void BaseEntity::addToObject(Object & obj) const if (contlist.size() != 0) { omap["contains"] = Object(contlist); } +#endif } oplist BaseEntity::externalMessage(const RootOperation & op) @@ -147,7 +127,7 @@ oplist BaseEntity::Operation(const Appearance & op) { oplist res; return(res); } oplist BaseEntity::Operation(const Disappearance & op) { oplist res; return(res); } oplist BaseEntity::Operation(const RootOperation & op) { oplist res; return(res); } -void BaseEntity::setRefno(oplist & ret, const RootOperation & ref_op) const +void BaseEntity::setRefno(const oplist& ret, const RootOperation & ref_op) const { for(oplist::const_iterator I = ret.begin(); I != ret.end(); I++) { setRefnoOp(*I, ref_op); diff --git a/common/BaseEntity.h b/common/BaseEntity.h index dfe90614d..e3c4cd549 100644 --- a/common/BaseEntity.h +++ b/common/BaseEntity.h @@ -1,13 +1,12 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef BASE_ENTITY_H #define BASE_ENTITY_H #include -#include #include #include @@ -17,27 +16,20 @@ class BaseEntity { public: int seq; // Sequence number string fullid; // String id - string name; // Name - Location location; // Full details of location inc. ref pos and vel - list_t contains; // List of entities which use this as ref - bool deleted; // true if deleted bool inGame; // true if in game object - bool omnipresent; // true if omnipresent in game. - WorldRouter * world; // Exists in this world. BaseEntity(); - virtual ~BaseEntity() { } + virtual ~BaseEntity(); - Vector3D getXyz() const; virtual void destroy(); Atlas::Message::Object asObject() const; virtual void addToObject(Atlas::Message::Object &) const; - virtual oplist externalMessage(const RootOperation & op); virtual oplist message(const RootOperation & op); virtual oplist operation(const RootOperation & op); virtual oplist externalOperation(const RootOperation & op); + virtual oplist externalMessage(const RootOperation & op); virtual oplist Operation(const Login & op); virtual oplist Operation(const Logout & op); @@ -67,7 +59,7 @@ class BaseEntity { virtual oplist Operation(const Disappearance & op); virtual oplist Operation(const RootOperation & op); - void setRefno(oplist & ret, const RootOperation & ref_op) const; + void setRefno(const oplist & ret, const RootOperation & ref_op) const; op_no_t opEnumerate(const RootOperation & op) const; oplist callOperation(const RootOperation & op); oplist error(const RootOperation & op, const char * errstring) const; @@ -78,9 +70,4 @@ class BaseEntity { }; -inline ostream & operator<<(ostream& s, Location& v) -{ - return s << "{" << v.ref->fullid << "," << v.coords << "," << v.velocity << "}"; -} - -#endif /* BASE_ENTITY_H */ +#endif // BASE_ENTITY_H diff --git a/common/Chop.h b/common/Chop.h index 183b78ac1..e47b73415 100644 --- a/common/Chop.h +++ b/common/Chop.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_CHOP_H #define COMMON_CHOP_H @@ -28,4 +28,4 @@ class Chop : public RootOperation { } } } -#endif /* COMMON_CHOP_H */ +#endif // COMMON_CHOP_H diff --git a/common/Cut.h b/common/Cut.h index 933687412..9e6c4c386 100644 --- a/common/Cut.h +++ b/common/Cut.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_CUT_H #define COMMON_CUT_H @@ -28,4 +28,4 @@ class Cut : public RootOperation { } } } -#endif /* COMMON_CUT_H */ +#endif // COMMON_CUT_H diff --git a/common/Eat.h b/common/Eat.h index 0c1b3a709..0c451a9ca 100644 --- a/common/Eat.h +++ b/common/Eat.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_EAT_H #define COMMON_EAT_H @@ -28,4 +28,4 @@ class Eat : public RootOperation { } } } -#endif /* COMMON_EAT_H */ +#endif // COMMON_EAT_H diff --git a/common/Fire.h b/common/Fire.h index a36c8ecff..12cb5ef3f 100644 --- a/common/Fire.h +++ b/common/Fire.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_FIRE_H #define COMMON_FIRE_H @@ -28,4 +28,4 @@ class Fire : public RootOperation { } } } -#endif /* COMMON_FIRE_H */ +#endif // COMMON_FIRE_H diff --git a/common/Load.h b/common/Load.h index abc3cb250..638c3ca25 100644 --- a/common/Load.h +++ b/common/Load.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_LOAD_H #define COMMON_LOAD_H @@ -28,4 +28,4 @@ class Load : public RootOperation { } } } -#endif /* COMMON_LOAD_H */ +#endif // COMMON_LOAD_H diff --git a/common/Nourish.h b/common/Nourish.h index 0e2e8771d..2cdd58287 100644 --- a/common/Nourish.h +++ b/common/Nourish.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_NOURISH_H #define COMMON_NOURISH_H @@ -28,4 +28,4 @@ class Nourish : public RootOperation { } } } -#endif /* COMMON_NOURISH_H */ +#endif // COMMON_NOURISH_H diff --git a/common/Save.h b/common/Save.h index e21556188..56ee5a60b 100644 --- a/common/Save.h +++ b/common/Save.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_SAVE_H #define COMMON_SAVE_H @@ -28,4 +28,4 @@ class Save : public RootOperation { } } } -#endif /* COMMON_SAVE_H */ +#endif // COMMON_SAVE_H diff --git a/common/Setup.h b/common/Setup.h index 3f30d72c5..51016743e 100644 --- a/common/Setup.h +++ b/common/Setup.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_SETUP_H #define COMMON_SETUP_H @@ -28,4 +28,4 @@ class Setup : public RootOperation { } } } -#endif /* COMMON_SETUP_H */ +#endif // COMMON_SETUP_H diff --git a/common/Tick.h b/common/Tick.h index aa578df0f..269fe135b 100644 --- a/common/Tick.h +++ b/common/Tick.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_TICK_H #define COMMON_TICK_H @@ -28,4 +28,4 @@ class Tick : public RootOperation { } } } -#endif /* COMMON_TICK_H */ +#endif // COMMON_TICK_H diff --git a/common/config.h b/common/config.h index f0bc3164a..a357dd76a 100644 --- a/common/config.h +++ b/common/config.h @@ -7,4 +7,4 @@ #include "../config.h" -#endif /* CONFIG_H */ +#endif // CONFIG_H diff --git a/common/const.cpp b/common/const.cpp index 525ddbe06..375dbce47 100644 --- a/common/const.cpp +++ b/common/const.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #if 0 diff --git a/common/const.h b/common/const.h index d512bb84d..a82de20d5 100644 --- a/common/const.h +++ b/common/const.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_CONST_H #define COMMON_CONST_H @@ -29,4 +29,4 @@ namespace consts { } -#endif /* COMMON_CONST_H */ +#endif // COMMON_CONST_H diff --git a/common/database.cpp b/common/database.cpp index d44c51004..91554ae16 100644 --- a/common/database.cpp +++ b/common/database.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include // #include @@ -14,7 +14,7 @@ #include "database.h" -// It seems that gcc does not yet include sstream.h +// It seems that GNU libstdc++ does not yet include sstream.h // Included is a version written explicitly for gcc, which will be used // if the header is not present. #ifdef HAVE_SSTREAM_H diff --git a/common/database.h b/common/database.h index 3f25b0f7b..a86f7f522 100644 --- a/common/database.h +++ b/common/database.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef DATABSE_H #define DATABSE_H diff --git a/common/debug.h b/common/debug.h index 2057f76b7..1985024b2 100644 --- a/common/debug.h +++ b/common/debug.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_DEBUG_H #define COMMON_DEBUG_H diff --git a/common/globals.cpp b/common/globals.cpp index ba22e07bc..05c54b1e6 100644 --- a/common/globals.cpp +++ b/common/globals.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include "globals.h" #include "config.h" diff --git a/common/globals.h b/common/globals.h index 5d2aa6145..1ea873b1f 100644 --- a/common/globals.h +++ b/common/globals.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef COMMON_GLOBALS_H #define COMMON_GLOBALS_H @@ -15,4 +15,4 @@ extern std::string install_directory; extern std::list rulesets; extern bool exit_flag; -#endif /* COMMON_GLOBALS_H */ +#endif // COMMON_GLOBALS_H diff --git a/common/log.cpp b/common/log.cpp index a5767f30e..2a5611619 100644 --- a/common/log.cpp +++ b/common/log.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch extern "C" { #include diff --git a/common/op_switch.h b/common/op_switch.h index 3788de745..7598e255b 100644 --- a/common/op_switch.h +++ b/common/op_switch.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef OP_SWITCH_H #define OP_SWITCH_H @@ -138,4 +138,4 @@ break; \ } -#endif /* OP_SWITCH_H */ +#endif // OP_SWITCH_H diff --git a/common/operations.h b/common/operations.h index e93a3ef9d..3d3cdb294 100644 --- a/common/operations.h +++ b/common/operations.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef OPERATIONS_H #define OPERATIONS_H @@ -72,4 +72,4 @@ using Atlas::Objects::Operation::Cut; using Atlas::Objects::Operation::Chop; using Atlas::Objects::Operation::Fire; -#endif /* OPERATIONS_H */ +#endif // OPERATIONS_H diff --git a/common/persistance.cpp b/common/persistance.cpp index 5e50a8abf..893c94f46 100644 --- a/common/persistance.cpp +++ b/common/persistance.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include // #include @@ -26,6 +26,8 @@ #include "sstream.h" #endif +using Atlas::Message::Object; + bool Persistance::restricted = false; Persistance * Persistance::instance() @@ -86,23 +88,25 @@ Account * Persistance::load_admin_account() bool Persistance::findAccount(const std::string & name) { - Atlas::Message::Object account; + Object account; return getObject(account_db, name.c_str(), account); } Account * Persistance::getAccount(const std::string & name) { - Atlas::Message::Object account; + Object account; if (!getObject(account_db, name.c_str(), account)) { return NULL; } - Atlas::Message::Object::MapType acmap = account.AsMap(); - if ((acmap.find("id")==acmap.end())||(acmap.find("password")==acmap.end())){ + const Object::MapType & acmap = account.AsMap(); + Object::MapType::const_iterator I = acmap.find("id"), + J = acmap.find("password"); + if ((I == acmap.end()) || (J == acmap.end())){ cerr << "Database account entry " << name << " is missing essential fields." << endl << flush; return NULL; } - Atlas::Message::Object & acn = acmap["id"], acp = acmap["password"]; + const Object & acn = I->second, & acp = J->second; if (!acn.IsString() || !acp.IsString()) { cerr << "Database account entry " << name << " is corrupt." << endl << flush; diff --git a/common/persistance.h b/common/persistance.h index c28bcdbbc..f28005cb3 100644 --- a/common/persistance.h +++ b/common/persistance.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef PERSISTANCE_H #define PERSISTANCE_H @@ -33,4 +33,4 @@ class Persistance : public Database { void putEntity(const BaseEntity *); }; -#endif /* PERSISTANCE_H */ +#endif // PERSISTANCE_H diff --git a/common/random.h b/common/random.h index 22ff0623c..5b73296d8 100644 --- a/common/random.h +++ b/common/random.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_RANDOM_H #define COMMON_RANDOM_H diff --git a/common/types.h b/common/types.h index f0c920a09..88b698adf 100644 --- a/common/types.h +++ b/common/types.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMMON_TYPES_H #define COMMON_TYPES_H @@ -11,6 +11,7 @@ #include class BaseEntity; +class Entity; typedef enum op_no { OP_LOGIN, @@ -47,6 +48,10 @@ typedef std::map dict_t; typedef std::list list_t; typedef std::pair idpair_t; -typedef std::vector oplist; +typedef std::map edict_t; +typedef std::list elist_t; -#endif /* TYPES_H */ +typedef std::vector oplist; +typedef std::list opqueue; + +#endif // TYPES_H diff --git a/common/utility.cpp b/common/utility.cpp index ae3505613..f709dd234 100644 --- a/common/utility.cpp +++ b/common/utility.cpp @@ -16,11 +16,12 @@ Root * Object_asRoot(const Atlas::Message::Object & o) Root * obj; if (!o.IsMap()) return NULL; - if ((o.AsMap().find("objtype") != o.AsMap().end()) && - ((*o.AsMap().find("objtype")).second.IsString())) { - if ((*o.AsMap().find("objtype")).second.AsString() == "object") { + Object::MapType::const_iterator I = o.AsMap().find("objtype"); + if ((I != o.AsMap().end()) && + (I->second.IsString())) { + if (I->second.AsString() == "object") { obj = new RootEntity; - } else if ((*o.AsMap().find("objtype")).second.AsString() == "op") { + } else if (I->second.AsString() == "op") { obj = new RootOperation; } else { obj = new Root; diff --git a/common/utility.h b/common/utility.h index 9f48e6ef4..b9b9e4315 100644 --- a/common/utility.h +++ b/common/utility.h @@ -16,4 +16,4 @@ Root * Object_asRoot(const Atlas::Message::Object &); } -#endif /* COMMON_UTILITY_H */ +#endif // COMMON_UTILITY_H diff --git a/modules/DateTime.cpp b/modules/DateTime.cpp index 9a3cbcd5b..8ee6c0a82 100644 --- a/modules/DateTime.cpp +++ b/modules/DateTime.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include "DateTime.h" diff --git a/modules/DateTime.h b/modules/DateTime.h index 6ee6412de..0c7688ec3 100644 --- a/modules/DateTime.h +++ b/modules/DateTime.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef DATE_TIME_H #define DATE_TIME_H @@ -47,4 +47,4 @@ class DateTime { unsigned int mpy() { return m_mpy; } }; -#endif /* DATE_TIME_H */ +#endif // DATE_TIME_H diff --git a/modules/Location.cpp b/modules/Location.cpp index 0a1a11c63..0071a4743 100644 --- a/modules/Location.cpp +++ b/modules/Location.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -13,7 +13,7 @@ #include "Location.h" -#include +#include using Atlas::Message::Object; diff --git a/modules/Location.h b/modules/Location.h index 7ba5586bb..c49ef9735 100644 --- a/modules/Location.h +++ b/modules/Location.h @@ -1,17 +1,17 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef LOCATION_H #define LOCATION_H #include -class BaseEntity; +class Entity; class Location { public: - BaseEntity * ref; + Entity * ref; Vector3D coords; // Coords relative to ref entity Vector3D velocity; // Veclociy vector, relative to ref entity. Vector3D face; // Bad way of representing direction entity faces. @@ -20,12 +20,12 @@ public: // which is equivalient to the SW corner is at coords. bool solid; - Location() : ref(NULL) { } - Location(BaseEntity * rf, const Vector3D& crds) : + Location() : ref(NULL), solid(true) { } + Location(Entity * rf, const Vector3D& crds) : ref(rf), coords(crds), solid(true) { } - Location(BaseEntity * rf, const Vector3D& crds, const Vector3D& vel) : + Location(Entity * rf, const Vector3D& crds, const Vector3D& vel) : ref(rf), coords(crds), velocity(vel), solid(true) { } - Location(BaseEntity * rf, const Vector3D& crds, const Vector3D& vel, + Location(Entity * rf, const Vector3D& crds, const Vector3D& vel, const Vector3D& fce) : ref(rf), coords(crds), velocity(vel), face(fce), solid(true) { } @@ -63,15 +63,15 @@ public: return coords.hitBox(m, bbox, other.coords + om, other.bbox); } - double hitTime(const Location & other) const { + double hitTime(const Location & other, int & axis) const { if (!other.bbox) { return -1; } const Vector3D & m = bmedian ? bmedian : bbox ? bbox : Vector3D(0,0,0); const Vector3D & om = other.bmedian ? other.bmedian : other.bbox; if (other.velocity) { return coords.hitTime(m, bbox, velocity, other.velocity, - other.coords + om, other.bbox); + other.coords + om, other.bbox, axis); } - return coords.hitTime(m, bbox, velocity, other.coords + om, other.bbox); + return coords.hitTime(m, bbox, velocity, other.coords + om, other.bbox, axis); } double inTime(const Location & other) const { @@ -84,4 +84,4 @@ public: friend ostream & operator<<(ostream& s, Location& v); }; -#endif /* LOCATION_H */ +#endif // LOCATION_H diff --git a/modules/Makefile.am b/modules/Makefile.am index 646588945..392a38360 100644 --- a/modules/Makefile.am +++ b/modules/Makefile.am @@ -1,4 +1,5 @@ noinst_LIBRARIES = libmodules.a libmodules_a_SOURCES = DateTime.cpp DateTime.h \ - Location.cpp Location.h + WorldTime.cpp WorldTime.h \ + Location.cpp Location.h diff --git a/physics/Vector3D.cpp b/physics/Vector3D.cpp index 0ef6ead35..ab3faaf65 100644 --- a/physics/Vector3D.cpp +++ b/physics/Vector3D.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include diff --git a/physics/Vector3D.h b/physics/Vector3D.h index 03813dd5e..ea48a4fb8 100644 --- a/physics/Vector3D.h +++ b/physics/Vector3D.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef VECTOR_3D_H #define VECTOR_3D_H @@ -48,15 +48,18 @@ class Vector3D { double x,y,z; bool _set; public: + static const int cX = 0; // Used to indicate which axis + static const int cY = 1; + static const int cZ = 2; Vector3D() : x(0), y(0), z(0), _set(false) { } Vector3D(double size) : x(size), y(size), z(size), _set(true) { } Vector3D(double x, double y, double z) : x(x), y(y), z(z), _set(true) { } - Vector3D(const Object::ListType & vector) { + Vector3D(const Object::ListType & vector) : _set(true) { Object::ListType::const_iterator I = vector.begin(); - x = I->AsNum(); I++; - y = I->AsNum(); I++; - z = I->AsNum(); + x = I->AsNum(); + y = (++I)->AsNum(); + z = (++I)->AsNum(); } double X() const { return x; } @@ -68,27 +71,27 @@ class Vector3D { return ((x==other.x) && (y==other.y) && (z==other.z)); } - Vector3D operator+(const Vector3D & other) const { + const Vector3D operator+(const Vector3D & other) const { // Add two vectors return Vector3D(x+other.x, y+other.y, z+other.z); } - Vector3D operator+(double other) const { + const Vector3D operator+(double other) const { // Increaese size (in all direction for boxes) return Vector3D(x+other, y+other, z+other); } - Vector3D operator-(const Vector3D & other) const { + const Vector3D operator-(const Vector3D & other) const { // Subtract two vectors return Vector3D(x-other.x, y-other.y, z-other.z); } - Vector3D operator*(double other) const { + const Vector3D operator*(double other) const { // Multiply vector by number return Vector3D(x*other,y*other,z*other); } - Vector3D operator/(double other) const { + const Vector3D operator/(double other) const { // Divide vector by number return Vector3D(x/other,y/other,z/other); } @@ -99,11 +102,11 @@ class Vector3D { double & operator[](int index) { switch(index) { - case 0: + case cX: return(x); - case 1: + case cY: return(y); - case 2: + case cZ: return(z); default: //Throw an exception here maybe @@ -120,7 +123,7 @@ class Vector3D { return x * v.x + y * v.y + z * v.z; } - Vector3D cross(const Vector3D & v) const { + const Vector3D cross(const Vector3D & v) const { //"Cross product of a vector"; return Vector3D(y*v.z - z*v.x, z*v.x - x*v.z, x*v.y - y*v.z); } @@ -154,13 +157,13 @@ class Vector3D { return d / (v.mag() * mag()); } - Vector3D unitVector() const { + const Vector3D unitVector() const { //"return the unit vector of a vector"; // This is could throw a wobbly return operator/(mag()); } - Vector3D unitVectorTo(const Vector3D & v) const { + const Vector3D unitVectorTo(const Vector3D & v) const { // return the unit vector in the direction of another vector; Vector3D difference_vector = v - (*this); return difference_vector.unitVector(); @@ -194,7 +197,7 @@ class Vector3D { } double hitTime(const Vector3D & m, const Vector3D & s, const Vector3D & v, - const Vector3D & om, const Vector3D & os) const { + const Vector3D & om, const Vector3D & os, int & axis) const { // When is box defined by this vector, with median offset m of size s // velocity v, colliding with other box of median om of size s. // If this function returns a -ve value, it is possible they are @@ -212,12 +215,13 @@ class Vector3D { double end = min(max(xt), min(max(yt),max(zt))); // If the start is before the end, then there is a collision if (end < start) { return -1; } + axis = ((start == min(xt)) ? cX : ((start == min(yt)) ? cY : cZ)); return start; } double hitTime(const Vector3D & m, const Vector3D & s, const Vector3D & v, const Vector3D & ov, - const Vector3D & om, const Vector3D & os) const { + const Vector3D & om, const Vector3D & os, int & axis) const { // This is the same as the above function but it accepts an // additional arguemnt, the velocity of the other entity // Calculate range of times each intersect @@ -230,6 +234,7 @@ class Vector3D { double end = min(max(xt), min(max(yt),max(zt))); // If the start is before the end, then there is a collision if (end < start) { return -1; } + axis = ((start == min(xt)) ? cX : ((start == min(yt)) ? cY : cZ)); return start; } @@ -245,7 +250,7 @@ class Vector3D { return leave; } - Object asObject() const { + const Object asObject() const { Object::ListType coords; coords.push_back(Object(x)); coords.push_back(Object(y)); @@ -262,4 +267,4 @@ inline ostream & operator<<(ostream& s, const Vector3D& v) { } -#endif VECTOR_3D_H +#endif // VECTOR_3D_H diff --git a/physics/VectorPol.h b/physics/VectorPol.h index d7cf0423b..56a6a6fd0 100644 --- a/physics/VectorPol.h +++ b/physics/VectorPol.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef VECTOR_POL_H #define VECTOR_POL_H diff --git a/rulesets/BaseMind.cpp b/rulesets/BaseMind.cpp index 92887f18f..9f550faa8 100644 --- a/rulesets/BaseMind.cpp +++ b/rulesets/BaseMind.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -266,10 +266,10 @@ oplist BaseMind::Operation(const Appearance & op) { oplist(res); script->Operation("appearance", op, res); - Object::ListType args = op.GetArgs(); - Object::ListType::iterator I; + const Object::ListType & args = op.GetArgs(); + Object::ListType::const_iterator I; for(I = args.begin(); I != args.end(); I++) { - map.getAdd(I->AsMap()["id"].AsString()); + map.getAdd(I->AsMap().find("id")->second.AsString()); } return res; } diff --git a/rulesets/BaseMind.h b/rulesets/BaseMind.h index 73d304cbd..96e42a8d2 100644 --- a/rulesets/BaseMind.h +++ b/rulesets/BaseMind.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef BASE_MIND_H #define BASE_MIND_H @@ -47,4 +47,4 @@ class BaseMind : public Entity { friend class PythonMindScript; }; -#endif /* BASE_MIND_H */ +#endif // BASE_MIND_H diff --git a/rulesets/Character.cpp b/rulesets/Character.cpp index a2e4b3bf2..26754d76e 100644 --- a/rulesets/Character.cpp +++ b/rulesets/Character.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -45,6 +45,7 @@ extern "C" { #include "ExternalMind.h" #include "Script.h" #include "Python_API.h" // FIXME This must go +#include "World.h" #include @@ -84,9 +85,9 @@ oplist Character::metabolise(double ammount = 1) return oplist(1,s); } -Character::Character() : movement(*new Pedestrian(*this)), autom(0), mind(NULL), - externalMind(NULL), drunkness(0.0), - sex("female"), food(0), maxWeight(100) +Character::Character() : movement(*new Pedestrian(*this)), autom(false), + drunkness(0.0), sex("female"), food(0), maxWeight(100), + mind(NULL), externalMind(NULL) { isCharacter = true; weight = 60; @@ -162,7 +163,7 @@ oplist Character::Operation(const Setup & op) Look * l = new Look(Look::Instantiate()); l->SetTo(world->fullid); res2[1] = l; - if (location.ref != world) { + if (location.ref != &world->gameWorld) { l = new Look(Look::Instantiate()); l->SetTo(location.ref->fullid); res2.push_back(l); @@ -186,10 +187,10 @@ oplist Character::Operation(const Tick & op) const Object::ListType & args = op.GetArgs(); if ((0 != args.size()) && (args.front().IsMap())) { // Deal with movement. - Object::MapType arg1 = args.front().AsMap(); - if ((arg1.find("serialno") != arg1.end()) && - (arg1["serialno"].IsInt())) { - if (arg1["serialno"].AsInt() < movement.serialno) { + const Object::MapType & arg1 = args.front().AsMap(); + Object::MapType::const_iterator I = arg1.find("serialno"); + if ((I != arg1.end()) && (I->second.IsInt())) { + if (I->second.AsInt() < movement.serialno) { debug(cout << "Old tick" << endl << flush;); return oplist(); } @@ -283,7 +284,7 @@ oplist Character::Operation(const Eat & op) n->SetTo(to); n->SetArgs(Object::ListType(1,nour_ent)); - oplist res2; + oplist res2(2); res2[0] = s; res2[1] = n; return res2; @@ -291,8 +292,8 @@ oplist Character::Operation(const Eat & op) oplist Character::Operation(const Nourish & op) { - Object::MapType nent = op.GetArgs().front().AsMap(); - food = food + nent["weight"].AsNum(); + const Object::MapType & nent = op.GetArgs().front().AsMap(); + food = food + nent.find("weight")->second.AsNum(); Object::MapType food_ent; food_ent["id"] = fullid; @@ -330,23 +331,24 @@ oplist Character::mindOperation(const Tick & op) oplist Character::mindOperation(const Move & op) { debug( cout << "Character::mind_move_op" << endl << flush;); - Move * newop = new Move(op); const Object::ListType & args = op.GetArgs(); if ((0 == args.size()) || (!args.front().IsMap())) { cerr << "move op has no argument" << endl << flush; return oplist(); } - Object::MapType arg1 = args.front().AsMap(); - if ((arg1.find("id") == arg1.end()) || !arg1["id"].IsString()) { + const Object::MapType & arg1 = args.front().AsMap(); + Object::MapType::const_iterator I = arg1.find("id"); + if ((I == arg1.end()) || !I->second.IsString()) { cerr << "Its got no id" << endl << flush; } - string & oname = arg1["id"].AsString(); - if (world->objects.find(oname) == world->objects.end()) { + const string & oname = I->second.AsString(); + edict_t::const_iterator J = world->eobjects.find(oname); + if (J == world->eobjects.end()) { debug( cout << "This move op is for a phoney object" << endl << flush;); - delete newop; return oplist(); } - Thing * obj = (Thing *)world->objects[oname]; + Move * newop = new Move(op); + Entity * obj = J->second; if (obj != this) { debug( cout << "Moving something else. " << oname << endl << flush;); if ((obj->weight < 0) || (obj->weight > weight)) { @@ -358,78 +360,45 @@ oplist Character::mindOperation(const Move & op) return oplist(1,newop); } string location_ref; - if ((arg1.find("loc") != arg1.end()) && (arg1["loc"].IsString())) { - location_ref = arg1["loc"].AsString(); + I = arg1.find("loc"); + if ((I != arg1.end()) && (I->second.IsString())) { + location_ref = I->second.AsString(); } else { debug( cout << "Parent not set" << endl << flush;); } Vector3D location_coords; - if ((arg1.find("pos") != arg1.end()) && (arg1["pos"].IsList())) { - Object::ListType vector = arg1["pos"].AsList(); - if (vector.size()==3) { - try { - // FIXME - //double x = vector.front().AsFloat(); - //vector.pop_front(); - //double y = vector.front().AsFloat(); - //vector.pop_front(); - //double z = vector.front().AsFloat(); - double x = vector[0].AsFloat(); - double y = vector[1].AsFloat(); - double z = vector[2].AsFloat(); - location_coords = Vector3D(x, y, z); - debug( cout << "Got new format coords: " << location_coords << endl << flush;); - } - catch (Atlas::Message::WrongTypeException) { - cerr << "EXCEPTION: Malformed pos move operation" << endl << flush; - } + I = arg1.find("pos"); + if ((I != arg1.end()) /* && (I->second.IsList()) */) { + try { + location_coords = Vector3D(I->second.AsList()); + } + catch (Atlas::Message::WrongTypeException) { + cerr << "EXCEPTION: Malformed pos move operation" << endl << flush; } } Vector3D location_vel; - if ((arg1.find("velocity") != arg1.end()) && (arg1["velocity"].IsList())) { - Object::ListType vector = arg1["velocity"].AsList(); - if (vector.size()==3) { - try { - // FIXME - //double x = vector.front().AsFloat(); - //vector.pop_front(); - //double y = vector.front().AsFloat(); - //vector.pop_front(); - //double z = vector.front().AsFloat(); - double x = vector[0].AsFloat(); - double y = vector[1].AsFloat(); - double z = vector[2].AsFloat(); - location_vel = Vector3D(x, y, z); - debug( cout << "Got new format velocity: " << location_vel << endl << flush;); - } - catch (Atlas::Message::WrongTypeException) { - cerr << "EXCEPTION: Malformed vel move operation" << endl << flush; - } + I = arg1.find("velocity"); + if ((I != arg1.end()) /* && (I->second.IsList()) */) { + try { + location_vel = Vector3D(I->second.AsList()); + } + catch (Atlas::Message::WrongTypeException) { + cerr << "EXCEPTION: Malformed vel move operation" << endl << flush; } } + Vector3D location_face; - if ((arg1.find("face") != arg1.end()) && (arg1["face"].IsList())) { - Object::ListType vector = arg1["face"].AsList(); - if (vector.size()==3) { - try { - // FIXME - //double x = vector.front().AsFloat(); - //vector.pop_front(); - //double y = vector.front().AsFloat(); - //vector.pop_front(); - //double z = vector.front().AsFloat(); - double x = vector[0].AsFloat(); - double y = vector[1].AsFloat(); - double z = vector[2].AsFloat(); - location_face = Vector3D(x, y, z); - debug( cout << "Got new format face: " << location_face << endl << flush;); - } - catch (Atlas::Message::WrongTypeException) { - cerr << "EXCEPTION: Malformed face move operation" << endl << flush; - } + I = arg1.find("face"); + if ((I != arg1.end()) /* && (I->second.IsList()) */) { + try { + location_face = Vector3D(I->second.AsList()); + } + catch (Atlas::Message::WrongTypeException) { + cerr << "EXCEPTION: Malformed face move operation" << endl << flush; } } + if (!location_coords) { if (op.GetFutureSeconds() < 0) { newop->SetFutureSeconds(0); @@ -441,7 +410,7 @@ oplist Character::mindOperation(const Move & op) } double vel_mag; // Print out a bunch of debug info - debug( cout << ":" << location_ref << ":" << world->fullid << ":" << location.ref->fullid << ":" << endl << flush;); + debug( cout << ":" << location_ref << ":" << location.ref->fullid << ":" << endl << flush;); if ( //(location_ref==world->fullid) && (location_ref==location.ref->fullid) && (newop->GetFutureSeconds() >= 0) ) { @@ -490,22 +459,13 @@ oplist Character::mindOperation(const Move & op) Location ret_location; RootOperation * moveOp = movement.genMoveOperation(&ret_location); const Location & current_location = (NULL!=moveOp) ? ret_location : location; - //if (NULL!=moveOp) { - //current_location = ret_location; - //} else { - //current_location = location; - //} movement.reset(); if ((vel_mag==0) || !direction) { debug( cout << "\tMovement stopped" << endl << flush;); if (NULL != moveOp) { Object::ListType & args = moveOp->GetArgs(); Object::MapType & ent = args.front().AsMap(); - Object::ListType velocity; - velocity.push_back(Object(0.0)); - velocity.push_back(Object(0.0)); - velocity.push_back(Object(0.0)); - ent["velocity"]=Object(velocity); + ent["velocity"]=Vector3D(0,0,0).asObject(); ent["mode"]=Object("standing"); moveOp->SetArgs(args); } else { @@ -526,20 +486,15 @@ oplist Character::mindOperation(const Move & op) tickOp->SetTo(fullid); // Need to add the arguments to this op before we return it // direction is already a unit vector - if (!location_coords) { - debug( cout << "\tNo target location" << endl << flush;); - movement.targetLocation = Vector3D(); - } else { - debug( cout << "\tUsing target location" << endl << flush;); - movement.targetLocation = location_coords; - } - movement.velocity=direction*vel_mag; + debug( if (location_coords) { cout<<"\tUsing target"<SetFutureSeconds(movement.getTickAddition(location.coords)); debug( cout << "Next tick " << tickOp->GetFutureSeconds() << endl << flush;); - if (NULL!=moveOp2) { - if (NULL!=moveOp) { + if (NULL != moveOp2) { + if (NULL != moveOp) { delete moveOp; } moveOp=moveOp2; @@ -559,9 +514,10 @@ oplist Character::mindOperation(const Set & op) Set * s = new Set(op); const Object::ListType & args = op.GetArgs(); if (args.front().IsMap()) { - Object::MapType amap = args.front().AsMap(); - if (amap.find("id") != amap.end() && amap["id"].IsString()) { - string opid = amap["id"].AsString(); + const Object::MapType & amap = args.front().AsMap(); + Object::MapType::const_iterator I = amap.find("id"); + if (I != amap.end() && I->second.IsString()) { + const string & opid = I->second.AsString(); if (opid != fullid) { s->SetTo(opid); } @@ -584,7 +540,7 @@ oplist Character::mindOperation(const Create & op) { // We need to call, THE THING FACTORY! Or maybe not // This currently does nothing, so characters are not able to directly - // create objects. By and large a tool must be used. This should at some + // create eobjects. By and large a tool must be used. This should at some // point be able to send create operations on to other entities debug( cout << "Character::mindOperation(Create)" << endl << flush;); return oplist(); @@ -605,8 +561,8 @@ oplist Character::mindOperation(const Talk & op) oplist Character::mindOperation(const Look & op) { - debug( cout << "Got look up from mind from [" << op.GetFrom() - << "] to [" << op.GetTo() << "]" << endl << flush;); + debug(cout << "Got look up from mind from [" << op.GetFrom() + << "] to [" << op.GetTo() << "]" << endl << flush;); perceptive = true; Look * l = new Look(op); if (op.GetTo().size() == 0) { @@ -615,9 +571,10 @@ oplist Character::mindOperation(const Look & op) l->SetTo(world->fullid); } else { if (args.front().IsMap()) { - Object::MapType amap = args.front().AsMap(); - if (amap.find("id") != amap.end() && amap["id"].IsString()) { - l->SetTo(amap["id"].AsString()); + const Object::MapType & amap = args.front().AsMap(); + Object::MapType::const_iterator I = amap.find("id"); + if (I != amap.end() && I->second.IsString()) { + l->SetTo(I->second.AsString()); } } } @@ -658,9 +615,10 @@ oplist Character::mindOperation(const Touch & op) t->SetTo(world->fullid); } else { if (args.front().IsMap()) { - Object::MapType amap = args.front().AsMap(); - if (amap.find("id") != amap.end() && amap["id"].IsString()) { - t->SetTo(amap["id"].AsString()); + const Object::MapType & amap = args.front().AsMap(); + Object::MapType::const_iterator I = amap.find("id"); + if (I != amap.end() && I->second.IsString()) { + t->SetTo(I->second.AsString()); } } else if (args.front().IsString()) { t->SetTo(args.front().AsString()); @@ -844,24 +802,18 @@ oplist Character::sendMind(const RootOperation & op) // If there is some kinf of error in the connection, we turn autom on } else { //return(*(RootOperation **)NULL); - if (autom == 0) { + if (!autom) { debug( cout << "Turning automatic on for " << fullid << endl << flush;); - autom = 1; + autom = true; if (externalMind != NULL) { delete externalMind; externalMind = NULL; } } } - if (autom) { - debug( cout << "Using " << local_res.size() << " ops from local mind" - << endl << flush;); - //res = local_res; - } else { - debug( cout << "Using " << local_res.size() << " ops from external mind" - << endl << flush;); - //res = external_res; - } + debug(cout << "Using " << local_res.size() << " ops from " + << (autom ? "local mind" : "external mind") + << endl << flush;); const oplist & res = autom ? local_res : external_res; // At this point there is a bunch of conversion stuff that I don't // understand diff --git a/rulesets/Character.h b/rulesets/Character.h index 38d0486c6..98e4d4abd 100644 --- a/rulesets/Character.h +++ b/rulesets/Character.h @@ -1,27 +1,24 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef CHARACTER_H #define CHARACTER_H -class BaseMind; -class ExternalMind; -class Account; -class Character; -class Location; -class Movement; - #include "Thing.h" -#include - class Movement; +class BaseMind; +class ExternalMind; class Character : public Thing { protected: Movement & movement; - int autom; + bool autom; + double drunkness; + string sex; + double food; + double maxWeight; static const double energyConsumption = 0.001; static const double foodConsumption = 0.1; @@ -36,10 +33,6 @@ class Character : public Thing { public: BaseMind * mind; ExternalMind * externalMind; - double drunkness; - string sex; - double food; - double maxWeight; Character(); virtual ~Character(); @@ -103,4 +96,4 @@ class Character : public Thing { virtual oplist externalOperation(const RootOperation & op); }; -#endif /* CHARACTER_H */ +#endif // CHARACTER_H diff --git a/rulesets/CharacterFactory.cpp b/rulesets/CharacterFactory.cpp index d2e4f6403..0b47eabfc 100644 --- a/rulesets/CharacterFactory.cpp +++ b/rulesets/CharacterFactory.cpp @@ -1,16 +1,10 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch - -#include -#include -#include +// Copyright (C) 2000,2001 Alistair Riddoch #include "Character.h" #include "CharacterFactory.h" -CharacterFactory * CharacterFactory::m_instance = NULL; - Character * CharacterFactory::newThing() { return new Character(); diff --git a/rulesets/CharacterFactory.h b/rulesets/CharacterFactory.h index e77b0b7ab..0fb6998a3 100644 --- a/rulesets/CharacterFactory.h +++ b/rulesets/CharacterFactory.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef CHARACTER_FACTORY_H #define CHARACTER_FACTORY_H @@ -9,17 +9,9 @@ #include "Character.h" class CharacterFactory : public ThingFactory { - protected: - CharacterFactory() { } - static CharacterFactory * m_instance; public: - static CharacterFactory * instance() { - if (m_instance == NULL) { - m_instance = new CharacterFactory(); - } - return m_instance; - } + CharacterFactory() { } virtual Character * newThing(); }; -#endif /* CHARACTER_FACTORY_H */ +#endif // CHARACTER_FACTORY_H diff --git a/rulesets/Creator.cpp b/rulesets/Creator.cpp index c193faf29..9202078c3 100644 --- a/rulesets/Creator.cpp +++ b/rulesets/Creator.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -23,7 +23,6 @@ #include #include "Creator.h" - #include "ExternalMind.h" static const bool debug_flag = false; @@ -59,7 +58,7 @@ oplist Creator::operation(const RootOperation & op) if (op_no == OP_SETUP) { Look look = Look::Instantiate(); look.SetFrom(fullid); - return world->Operation(look); + return world->lookOperation(look); } return sendMind(op); } diff --git a/rulesets/Creator.h b/rulesets/Creator.h index 7017a0556..e1616d72c 100644 --- a/rulesets/Creator.h +++ b/rulesets/Creator.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef CREATOR_H #define CREATOR_H @@ -15,4 +15,4 @@ class Creator : public Character { virtual oplist externalOperation(const RootOperation & op); }; -#endif /* CREATOR_H */ +#endif // CREATOR_H diff --git a/rulesets/CreatorFactory.cpp b/rulesets/CreatorFactory.cpp index b0dae27fa..1eacbaf83 100644 --- a/rulesets/CreatorFactory.cpp +++ b/rulesets/CreatorFactory.cpp @@ -1,16 +1,10 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch - -#include -#include -#include +// Copyright (C) 2000,2001 Alistair Riddoch #include "Creator.h" #include "CreatorFactory.h" -CreatorFactory * CreatorFactory::m_instance = NULL; - Creator * CreatorFactory::newThing() { return new Creator(); diff --git a/rulesets/CreatorFactory.h b/rulesets/CreatorFactory.h index 943244d1d..a3ae68710 100644 --- a/rulesets/CreatorFactory.h +++ b/rulesets/CreatorFactory.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef CREATOR_FACTORY_H #define CREATOR_FACTORY_H @@ -9,17 +9,9 @@ #include "Creator.h" class CreatorFactory : public ThingFactory { - protected: - CreatorFactory() { } - static CreatorFactory * m_instance; public: - static CreatorFactory * instance() { - if (m_instance == NULL) { - m_instance = new CreatorFactory(); - } - return m_instance; - } + CreatorFactory() { } virtual Creator * newThing(); }; -#endif /* CREATOR_FACTORY_H */ +#endif // CREATOR_FACTORY_H diff --git a/rulesets/Entity.cpp b/rulesets/Entity.cpp index 7d2bc97e9..63ffd3819 100644 --- a/rulesets/Entity.cpp +++ b/rulesets/Entity.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -34,8 +34,9 @@ static const bool debug_flag = false; using Atlas::Message::Object; -Entity::Entity() : script(new Script), status(1), - type("thing"), isCharacter(false), weight(-1) +Entity::Entity() : script(new Script), world(NULL), status(1), + type("thing"), weight(-1), + isCharacter(false), deleted(false), omnipresent(false) { inGame = true; name = string("Foo"); @@ -56,24 +57,29 @@ const Object & Entity::operator[](const string & aname) attributes[aname] = Object(weight); } else if (aname == "contains") { Object::ListType contlist; - for(list_t::const_iterator I=contains.begin();I!=contains.end();I++) { + for(elist_t::const_iterator I=contains.begin();I!=contains.end();I++) { contlist.push_back(*I); } attributes[aname] = Object(contlist); - } else if (attributes.find(aname) == attributes.end()) { - attributes[aname] = Object(); + } else { + Object::MapType::iterator I = attributes.find(aname); + if (I == attributes.end()) { + attributes[aname] = Object(); + } } return(attributes[aname]); } void Entity::set(const string & aname, const Object & attr) { - if ((aname == "status") && attr.IsFloat()) { - status = attr.AsFloat(); + if ((aname == "status") && attr.IsNum()) { + status = attr.AsNum(); + } else if (aname == "id") { + return; } else if ((aname == "name") && attr.IsString()) { name = attr.AsString(); - } else if ((aname == "weight") && attr.IsFloat()) { - weight = attr.AsFloat(); + } else if ((aname == "weight") && attr.IsNum()) { + weight = attr.AsNum(); } else { attributes[aname] = attr; } @@ -88,6 +94,24 @@ MemMap * Entity::getMap() { return NULL; } +void Entity::destroy() +{ + if (deleted == true) { + return; + } + elist_t::const_iterator I; + for(I = contains.begin(); I != contains.end(); I++) { + Entity * obj = *I; + if (obj->deleted == false) { + obj->location.ref = location.ref; + obj->location.coords = location.coords + obj->location.coords; + } + } + if (location) { + location.ref->contains.remove(this); + } +} + void Entity::addToObject(Object & obj) const { Object::MapType & omap = obj.AsMap(); @@ -96,6 +120,14 @@ void Entity::addToObject(Object & obj) const omap["parents"] = Object(Object::ListType(1,Object(type))); // We need to have a list of keys to pull from attributes. location.addToObject(obj); + Object::ListType contlist; + elist_t::const_iterator I; + for(I = contains.begin(); I != contains.end(); I++) { + contlist.push_back(Object((*I)->fullid)); + } + if (contlist.size() != 0) { + omap["contains"] = Object(contlist); + } BaseEntity::addToObject(obj); } @@ -104,47 +136,67 @@ void Entity::merge(const Object::MapType & entmap) Object::MapType::const_iterator I; for (I=entmap.begin(); I!=entmap.end(); I++) { const string & key = I->first; - if ((key == "name") || (key == "id") || (key == "parents")) continue; + if ((key == "parents")||(key == "bbox") || (key == "bmedian")) continue; if ((key == "pos") || (key == "loc") || (key == "velocity")) continue; if ((key == "face") || (key == "contains")) continue; - attributes[key] = I->second; + set(key, I->second); } } -void Entity::getLocation(Object::MapType & entmap, dict_t & objects) +void Entity::getLocation(const Object::MapType & entmap, edict_t & eobjects) { debug( cout << "Thing::getLocation" << endl << flush;); - if (entmap.find("loc") != entmap.end()) { - debug( cout << "Thing::getLocation, getting it" << endl << flush;); - try { - const string & ref_id = entmap["loc"].AsString(); - if (objects.find(ref_id) == objects.end()) { - debug( cout << "ERROR: Can't get ref from objects dictionary" << endl << flush;); - return; - } - - location.ref = objects[ref_id]; - if (entmap.find("pos") != entmap.end()) { - location.coords = Vector3D(entmap["pos"].AsList()); - } - if (entmap.find("velocity") != entmap.end()) { - location.velocity = Vector3D(entmap["velocity"].AsList()); - } - if (entmap.find("face") != entmap.end()) { - location.face = Vector3D(entmap["face"].AsList()); - } else if (!location.face) { - location.face = Vector3D(1, 0, 0); - } - if (entmap.find("bbox") != entmap.end()) { - location.bbox = Vector3D(entmap["bbox"].AsList()); - } - if (entmap.find("bmedian") != entmap.end()) { - location.bmedian = Vector3D(entmap["bmedian"].AsList()); - } + Object::MapType::const_iterator I = entmap.find("loc"); + if (I == entmap.end()) { return; } + debug( cout << "Thing::getLocation, getting it" << endl << flush;); + try { + const string & ref_id = I->second.AsString(); + edict_t::const_iterator J = eobjects.find(ref_id); + if (J == eobjects.end()) { + debug( cout << "ERROR: Can't get ref from objects dictionary" << endl << flush;); + return; } - catch (Atlas::Message::WrongTypeException) { - cerr << "ERROR: Create operation has bad location" << endl << flush; + + location.ref = J->second; + I = entmap.find("pos"); + if (I != entmap.end()) { + location.coords = Vector3D(I->second.AsList()); } + I = entmap.find("velocity"); + if (I != entmap.end()) { + location.velocity = Vector3D(I->second.AsList()); + } + I = entmap.find("face"); + if (I != entmap.end()) { + location.face = Vector3D(I->second.AsList()); + } else if (!location.face) { + location.face = Vector3D(1, 0, 0); + } + I = entmap.find("bbox"); + if (I != entmap.end()) { + location.bbox = Vector3D(I->second.AsList()); + } + I = entmap.find("bmedian"); + if (I != entmap.end()) { + location.bmedian = Vector3D(I->second.AsList()); + } + } + catch (Atlas::Message::WrongTypeException) { + cerr << "ERROR: Create operation has bad location" << endl << flush; + } +} + +Vector3D Entity::getXyz() const +{ + //Location l=location; + if (!location) { + static Vector3D ret(0.0,0.0,0.0); + return ret; + } + if (location.ref) { + return location.coords+location.ref->getXyz(); + } else { + return location.coords; } } diff --git a/rulesets/Entity.h b/rulesets/Entity.h index 81c65db8a..0a04d1f23 100644 --- a/rulesets/Entity.h +++ b/rulesets/Entity.h @@ -1,16 +1,14 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef ENTITY_H #define ENTITY_H -#include - +#include #include -class Player; -class Routing; +class WorldRouter; class MemMap; class Script; @@ -19,10 +17,16 @@ class Entity : public BaseEntity { Script * script; Atlas::Message::Object::MapType attributes; public: - double status; - string type; - bool isCharacter; - double weight; + WorldRouter * world; // Exists in this world. + Location location; // Full details of location inc. ref pos and vel + elist_t contains; // List of entities which use this as ref + double status; // Health/damage coeficient + string type; // Easy access to primary parent + string name; // Entities name + double weight; // Weight in kg + bool isCharacter; // Is this a character + bool deleted; // Has this been deleted + bool omnipresent; // Is this omnipresent Entity(); virtual ~Entity(); @@ -30,10 +34,12 @@ class Entity : public BaseEntity { virtual const Atlas::Message::Object & operator[](const string & aname); virtual void set(const string & aname, const Atlas::Message::Object & attr); virtual MemMap * getMap(); + virtual void destroy(); int setScript(Script * scrpt); void merge(const Atlas::Message::Object::MapType &); - void getLocation(Atlas::Message::Object::MapType &, dict_t &); + void getLocation(const Atlas::Message::Object::MapType &, edict_t &); + Vector3D getXyz() const; virtual void addToObject(Atlas::Message::Object & obj) const; virtual oplist Operation(const Setup & op); @@ -55,4 +61,9 @@ class Entity : public BaseEntity { virtual oplist Operation(const Disappearance & op); }; -#endif /* ENTITY_H */ +inline ostream & operator<<(ostream& s, Location& v) +{ + return s << "{" << v.ref->fullid << "," << v.coords << "," << v.velocity << "}"; +} + +#endif // ENTITY_H diff --git a/rulesets/EntityFactory.cpp b/rulesets/EntityFactory.cpp index 847454ef9..7b6533ada 100644 --- a/rulesets/EntityFactory.cpp +++ b/rulesets/EntityFactory.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -22,6 +22,8 @@ #include #include +#include + #include "Character.h" #include "Creator.h" @@ -29,19 +31,17 @@ static const bool debug_flag = false; using Atlas::Message::Object; -// map * ThingShape::dict = NULL; - EntityFactory * EntityFactory::m_instance = NULL; EntityFactory::EntityFactory() { - factories["thing"] = ThingFactory::instance(); - factories["character"] = CharacterFactory::instance(); - factories["creator"] = CreatorFactory::instance(); - factories["plant"] = PlantFactory::instance(); - factories["food"] = FoodFactory::instance(); - factories["stackable"] = StackFactory::instance(); - factories["structure"] = StructureFactory::instance(); + factories["thing"] = new ThingFactory(); + factories["character"] = new CharacterFactory(); + factories["creator"] = new CreatorFactory(); + factories["plant"] = new PlantFactory(); + factories["food"] = new FoodFactory(); + factories["stackable"] = new StackFactory(); + factories["structure"] = new StructureFactory(); } void EntityFactory::readRuleset(const string & setname) @@ -49,24 +49,24 @@ void EntityFactory::readRuleset(const string & setname) global_conf->readFromFile(setname+".vconf"); } -Thing * EntityFactory::newThing(const string & type,const Object & ent, Routing * svr) +Thing * EntityFactory::newThing(const string & type,const Object & ent, WorldRouter * svr) { if (!ent.IsMap()) { debug( cout << "Entity is not a map" << endl << flush;); } - Object::MapType entmap = ent.AsMap(); Thing * thing = NULL; string py_package; + fdict_t::iterator I = factories.find(type); if (type.size() == 0) { thing = new Thing(); - } else if (factories.find(type) != factories.end()) { - thing = factories[type]->newThing(); + } else if (I != factories.end()) { + thing = I->second->newThing(); } else { - std::map::const_iterator I; - for(I = factories.begin(); I != factories.end(); I++) { - const string & f_type = I->first; + fdict_t::const_iterator J; + for(J = factories.begin(); J != factories.end(); J++) { + const string & f_type = J->first; if (global_conf->findItem(f_type, type)) { - thing = I->second->newThing(); + thing = J->second->newThing(); py_package = global_conf->getItem(f_type, type); } } @@ -80,13 +80,15 @@ Thing * EntityFactory::newThing(const string & type,const Object & ent, Routing if (py_package.size() != 0) { Create_PyThing(thing, py_package, type); } - if (entmap.find("name") != entmap.end() && entmap["name"].IsString()) { - thing->name = entmap["name"].AsString(); + const Object::MapType & entmap = ent.AsMap(); + Object::MapType::const_iterator K = entmap.find("name"); + if ((K != entmap.end()) && K->second.IsString()) { + thing->name = K->second.AsString(); } else { debug( cout << "Got no name" << endl << flush;); } thing->merge(entmap); // Get location from entity, if it is present - thing->getLocation(entmap, svr->objects); + thing->getLocation(entmap, svr->eobjects); return(thing); } diff --git a/rulesets/EntityFactory.h b/rulesets/EntityFactory.h index f55ea5106..b687083a8 100644 --- a/rulesets/EntityFactory.h +++ b/rulesets/EntityFactory.h @@ -1,22 +1,24 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef ENTITY_FACTORY_H #define ENTITY_FACTORY_H #include - -#include +#include class Thing; class ThingFactory; +class WorldRouter; + +typedef std::map fdict_t; class EntityFactory { EntityFactory(); static EntityFactory * m_instance; - std::map factories; + fdict_t factories; public: static EntityFactory * instance() { if (m_instance == NULL) { @@ -25,7 +27,7 @@ class EntityFactory { return m_instance; } void readRuleset(const string & file); - Thing * newThing(const string &, const Atlas::Message::Object &, Routing *); + Thing * newThing(const string &, const Atlas::Message::Object &, WorldRouter *); }; -#endif /* ENTITY_FACTORY_H */ +#endif // ENTITY_FACTORY_H diff --git a/rulesets/ExternalMind.cpp b/rulesets/ExternalMind.cpp index 06c1fca86..773ebe20a 100644 --- a/rulesets/ExternalMind.cpp +++ b/rulesets/ExternalMind.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include diff --git a/rulesets/ExternalMind.h b/rulesets/ExternalMind.h index 8e7840e76..27fbb4176 100644 --- a/rulesets/ExternalMind.h +++ b/rulesets/ExternalMind.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef EXTERNAL_MIND_H #define EXTERNAL_MIND_H @@ -18,4 +18,4 @@ class ExternalMind : public BaseMind { virtual oplist message(const RootOperation & op); }; -#endif /* EXTERNAL_MIND_H */ +#endif // EXTERNAL_MIND_H diff --git a/rulesets/Food.cpp b/rulesets/Food.cpp index 67c6f7376..408a468bb 100644 --- a/rulesets/Food.cpp +++ b/rulesets/Food.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -21,6 +21,10 @@ Food::Food() weight = 1; } +Food::~Food() +{ +} + oplist Food::Operation(const Eat & op) { oplist res; @@ -56,15 +60,16 @@ oplist Food::Operation(const Fire & op) return(res); } double cooked = 0; - if (attributes.find("cooked") == attributes.end()) { - cooked = attributes["cooked"].AsNum(); + Object::MapType::iterator I = attributes.find("cooked"); + if (I != attributes.end()) { + cooked = I->second.AsNum(); } - Object::MapType fire_ent = op.GetArgs().front().AsMap(); + const Object::MapType & fire_ent = op.GetArgs().front().AsMap(); Object::MapType self_ent; self_ent["id"] = fullid; // Currently this cooks pretty quick, and at the same speed for // everything. No mechanism for this yet. - double fire_size = fire_ent["status"].AsNum(); + double fire_size = fire_ent.find("status")->second.AsNum(); self_ent["cooked"] = cooked + (fire_size/weight); if (cooked > 1.0) { self_ent["status"] = status - (attributes["burn_speed"].AsNum()) * fire_size; diff --git a/rulesets/Food.h b/rulesets/Food.h index 991c9824e..5770fc1a4 100644 --- a/rulesets/Food.h +++ b/rulesets/Food.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef FOOD_H #define FOOD_H @@ -16,7 +16,7 @@ class Food : public Thing { public: Food(); - virtual ~Food() { } + virtual ~Food(); virtual oplist Operation(const Eat & op); virtual oplist Operation(const Fire & op); diff --git a/rulesets/FoodFactory.cpp b/rulesets/FoodFactory.cpp index 41afff937..43197d369 100644 --- a/rulesets/FoodFactory.cpp +++ b/rulesets/FoodFactory.cpp @@ -1,16 +1,10 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch - -#include -#include -#include +// Copyright (C) 2000,2001 Alistair Riddoch #include "Food.h" #include "FoodFactory.h" -FoodFactory * FoodFactory::m_instance = NULL; - Food * FoodFactory::newThing() { return new Food(); diff --git a/rulesets/FoodFactory.h b/rulesets/FoodFactory.h index 91ad8e35b..3580ef11c 100644 --- a/rulesets/FoodFactory.h +++ b/rulesets/FoodFactory.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef FOOD_FACTORY_H #define FOOD_FACTORY_H @@ -9,17 +9,9 @@ #include "Food.h" class FoodFactory : public ThingFactory { - protected: - FoodFactory() { } - static FoodFactory * m_instance; public: - static FoodFactory * instance() { - if (m_instance == NULL) { - m_instance = new FoodFactory(); - } - return m_instance; - } + FoodFactory() { } virtual Food * newThing(); }; -#endif /* FOOD_FACTORY_H */ +#endif // FOOD_FACTORY_H diff --git a/rulesets/Makefile.am b/rulesets/Makefile.am index 710ebfea6..f650edc61 100644 --- a/rulesets/Makefile.am +++ b/rulesets/Makefile.am @@ -12,6 +12,7 @@ librulesetmind_a_SOURCES = BaseMind.cpp BaseMind.h \ MemMap.cpp MemMap.h MemMap_methods.h librulesetentity_a_SOURCES = Thing.cpp Thing.h \ + World.cpp World.h \ Character.cpp Character.h \ Creator.cpp Creator.h \ Plant.cpp Plant.h \ diff --git a/rulesets/MemMap.cpp b/rulesets/MemMap.cpp index 971b0f258..c69832829 100644 --- a/rulesets/MemMap.cpp +++ b/rulesets/MemMap.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -22,25 +22,29 @@ Entity * MemMap::add(const Object & entity) if (!entity.IsMap()) { return NULL; } - Object::MapType entmap = entity.AsMap(); - if ((entmap.find("id") == entmap.end()) || - (entmap["id"].AsString().size() == 0)) { + const Object::MapType & entmap = entity.AsMap(); + Object::MapType::const_iterator I = entmap.find("id"); + if ((I == entmap.end()) || (I->second.AsString().size() == 0)) { return NULL; } - if (get(entmap["id"].AsString())) { + const string & id = I->second.AsString(); + if (get(id)) { return update(entity); } Entity * thing = new Entity; - thing->fullid = entmap["id"].AsString(); - if (entmap.find("name") != entmap.end() && entmap["name"].IsString()) { - thing->name = entmap["name"].AsString(); + thing->fullid = id; + I = entmap.find("name"); + if ((I != entmap.end()) && I->second.IsString()) { + thing->name = I->second.AsString(); } - if (entmap.find("type") != entmap.end() && entmap["type"].IsString()) { - thing->type = entmap["type"].AsString(); + I = entmap.find("type"); + if ((I != entmap.end()) && I->second.IsString()) { + thing->type = I->second.AsString(); } thing->merge(entmap); - if (entmap.find("loc") != entmap.end()) { - getAdd(entmap["loc"].AsString()); + I = entmap.find("loc"); + if (I != entmap.end()) { + getAdd(I->second.AsString()); } thing->getLocation(entmap, things); return addObject(thing); @@ -52,28 +56,32 @@ Entity * MemMap::update(const Object & entity) if (!entity.IsMap()) { return NULL; } - Object::MapType entmap = entity.AsMap(); - if (entmap.find("id") == entmap.end()) { + const Object::MapType & entmap = entity.AsMap(); + Object::MapType::const_iterator I = entmap.find("id"); + if (I == entmap.end()) { return NULL; } - string & id = entmap["id"].AsString(); + const string & id = I->second.AsString(); if (id.size() == 0) { return NULL; } debug( cout << " updating " << id << endl << flush;); - if (things.find(id) == things.end()) { + edict_t::iterator J = things.find(id); + if (J == things.end()) { return add(entity); } debug( cout << " " << id << " has already been spotted" << endl << flush;); - Entity * thing = (Entity*)things[id]; + Entity * thing = J->second; debug( cout << " got " << thing << endl << flush;); // I am not sure what the deal is with all the "needTrueValue stuff // below yet. FIXME find out exactly what is required. - if (entmap.find("name") != entmap.end() && entmap["name"].IsString()) { - thing->name = entmap["name"].AsString(); + I = entmap.find("name"); + if (I != entmap.end() && I->second.IsString()) { + thing->name = I->second.AsString(); } - if (entmap.find("type") != entmap.end() && entmap["type"].IsString()) { - thing->type = entmap["type"].AsString(); + I = entmap.find("type"); + if (I != entmap.end() && I->second.IsString()) { + thing->type = I->second.AsString(); } debug( cout << " got " << thing << endl << flush;); thing->merge(entmap); @@ -84,9 +92,9 @@ Entity * MemMap::update(const Object & entity) //setattr(obj,key,value); //} //} - list::const_iterator I; - for(I = updateHooks.begin(); I != updateHooks.end(); I++) { - script->hook(*I, thing); + list::const_iterator K; + for(K = updateHooks.begin(); K != updateHooks.end(); K++) { + script->hook(*K, thing); } //for (/*hook in MemMap::update_hooks*/) { //hook(obj); @@ -97,7 +105,7 @@ Entity * MemMap::update(const Object & entity) list MemMap::findByType(const string & what) { list res; - dict_t::const_iterator I; + edict_t::const_iterator I; for(I = things.begin(); I != things.end(); I++) { Entity * item = (Entity *)I->second; debug( cout << "F" << what << ":" << item->type << ":" << item->fullid << endl << flush;); @@ -111,7 +119,7 @@ list MemMap::findByType(const string & what) list MemMap::findByLocation(const Location & loc, double radius) { list res; - dict_t::const_iterator I; + edict_t::const_iterator I; for(I = things.begin(); I != things.end(); I++) { const Location & oloc = I->second->location; if (!loc || !oloc) { diff --git a/rulesets/MemMap.h b/rulesets/MemMap.h index 6a6ac8723..e1c8281e0 100644 --- a/rulesets/MemMap.h +++ b/rulesets/MemMap.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef MEM_MAP_H #define MEM_MAP_H @@ -14,8 +14,8 @@ class Script; class MemMap { friend class BaseMind; - dict_t things; - std::list additionsById; + edict_t things; + std::list additionsById; Script *& script; Entity * addObject(Entity * object); @@ -23,19 +23,18 @@ class MemMap { MemMap(Script *& s) : script(s) { } RootOperation * lookId(); - Entity * addId(const string & id); + Entity * addId(const std::string & id); Entity * add(const Object & entity); - void del(const string & id); - Entity * get(const string & id); - //Entity * __getitem__(const string & id) // operator[] perhaps? - Entity * getAdd(const string & id); + void del(const std::string & id); + Entity * get(const std::string & id); + Entity * getAdd(const std::string & id); Entity * update(const Object & entity); - list findByType(const string & what); - list findByLocation(const Location & where, double radius); + elist_t findByType(const std::string & what); + elist_t findByLocation(const Location & where, double radius); - list addHooks; - list updateHooks; - list deleteHooks; + std::list addHooks; + std::list updateHooks; + std::list deleteHooks; }; -#endif /* MEM_MAP_H */ +#endif // MEM_MAP_H diff --git a/rulesets/MemMap_methods.h b/rulesets/MemMap_methods.h index a84a1de1f..8ab0d42ed 100644 --- a/rulesets/MemMap_methods.h +++ b/rulesets/MemMap_methods.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include diff --git a/rulesets/MindFactory.cpp b/rulesets/MindFactory.cpp index 79cb3c2d8..571854211 100644 --- a/rulesets/MindFactory.cpp +++ b/rulesets/MindFactory.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -30,10 +30,6 @@ void MindFactory::readRuleset(const string & setname) BaseMind * MindFactory::newMind(const string & id, const string & name, const string & type,const Object & ent, Routing * svr) { - if (!ent.IsMap()) { - debug( cout << "Entity is not a map" << endl << flush;); - } - Object::MapType entmap = ent.AsMap(); BaseMind * mind = new BaseMind(id, name); string mind_class("NPCMind"), mind_package("mind.NPCMind"); if (global_conf->findItem("mind", type)) { diff --git a/rulesets/MindFactory.h b/rulesets/MindFactory.h index 1d8bb80ef..0eb1b6e6c 100644 --- a/rulesets/MindFactory.h +++ b/rulesets/MindFactory.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef ENTITY_FACTORY_H #define ENTITY_FACTORY_H @@ -30,4 +30,4 @@ class MindFactory { const Atlas::Message::Object &, Routing *); }; -#endif /* ENTITY_FACTORY_H */ +#endif // ENTITY_FACTORY_H diff --git a/rulesets/Movement.cpp b/rulesets/Movement.cpp index eafaa86c9..ca495bae7 100644 --- a/rulesets/Movement.cpp +++ b/rulesets/Movement.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -25,11 +25,10 @@ using Atlas::Message::Object; static const bool debug_flag = false; -Movement::Movement(Character & body) : body(body), targetRef(NULL) +Movement::Movement(Character & body) : body(body), lastMovementTime(-1), + velocity(0,0,0), serialno(0), + collRef(NULL), collAxis(-1) { - serialno=-1; - reset(); - debug( cout << "MOVEMENTINFO: " << lastMovementTime << endl << flush;); } Movement::~Movement() @@ -46,20 +45,22 @@ void Movement::checkCollisions(const Location & loc) // Check to see whether a collision is going to occur from now until the // the next tick in consts::basic_tick seconds double collTime = consts::basic_tick + 1; - list_t::const_iterator I; + elist_t::const_iterator I; // cout << "checking " << body->fullid << loc.coords << loc.velocity << " against "; - BaseEntity * collEntity = NULL; + Entity * collEntity = NULL; for(I = loc.ref->contains.begin(); I != loc.ref->contains.end(); I++) { // if ((*I) == loc.ref) { continue; } if ((*I) == &body) { continue; } const Location & oloc = (*I)->location; if (!oloc.bbox) { continue; } - double t = loc.hitTime(oloc); + int axis; + double t = loc.hitTime(oloc, axis); if (t < 0) { continue; } // cout << (*I)->fullid << oloc.coords << oloc.velocity; // cout << "[" << t << "]"; if (t < collTime) { collEntity = *I; + collAxis = axis; } collTime = min(collTime, t); } @@ -77,7 +78,7 @@ void Movement::checkCollisions(const Location & loc) collTime = min(collTime, t); if (collTime > consts::basic_tick) { return; } cout << "Collision with parent bounding box" << endl << flush; - targetRef = oloc.ref; + collRef = oloc.ref; } else if (!collEntity->location.solid) { cout << "Collision with non-solid object" << endl << flush; // Non solid container - check for collision with its contents. @@ -89,15 +90,15 @@ void Movement::checkCollisions(const Location & loc) for(I = lc2.ref->contains.begin(); I != lc2.ref->contains.end(); I++) { const Location & oloc = (*I)->location; if (!oloc.bbox) { continue; } - double t = rloc.hitTime(oloc); + double t = rloc.hitTime(oloc, collAxis); if (t < 0) { continue; } coll2Time = min(coll2Time, t); } if (coll2Time > collTime) { cout << "passing into it" << endl << flush; // We are entering collEntity. - // Set targetRef ???????????????? - targetRef = collEntity; + // Set collRef ???????????????? + collRef = collEntity; // if (coll2Time > consts::basic_tick) { return; } } } @@ -105,18 +106,20 @@ void Movement::checkCollisions(const Location & loc) if (collTime < getTickAddition(loc.coords)) { cout << "Setting target loc to " << loc.coords << "+" << loc.velocity << "*" << collTime; - targetLocation = loc.coords + loc.velocity * collTime; + collPos = loc.coords + loc.velocity * collTime; } else { - targetRef = NULL; + collRef = NULL; } } void Movement::reset() { serialno = serialno+1; - targetRef=NULL; - targetLocation=Vector3D(); - updatedLocation=Vector3D(); + collRef = NULL; + collPos = Vector3D(); + collAxis = -1; + targetPos=Vector3D(); + updatedPos=Vector3D(); velocity=Vector3D(0,0,0); lastMovementTime=body.world->getTime(); } diff --git a/rulesets/Movement.h b/rulesets/Movement.h index ef14b2d43..5956726a6 100644 --- a/rulesets/Movement.h +++ b/rulesets/Movement.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef MOVEMENT_H #define MOVEMENT_H @@ -13,12 +13,14 @@ class Movement { protected: Character & body; double lastMovementTime; - BaseEntity * targetRef; - Vector3D targetLocation; - Vector3D updatedLocation; + Vector3D targetPos; + Vector3D updatedPos; Vector3D velocity; Vector3D face; int serialno; + Vector3D collPos; + Entity * collRef; + int collAxis; bool updateNeeded(const Location & location) const; void checkCollisions(const Location & loc); @@ -36,4 +38,4 @@ class Movement { virtual Move * genMoveOperation(Location *) = 0; }; -#endif /* MOVEMENT_H */ +#endif // MOVEMENT_H diff --git a/rulesets/Pedestrian.cpp b/rulesets/Pedestrian.cpp index 8fceed975..190c4ef9c 100644 --- a/rulesets/Pedestrian.cpp +++ b/rulesets/Pedestrian.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -36,8 +36,9 @@ Pedestrian::~Pedestrian() double Pedestrian::getTickAddition(const Vector3D & coordinates) const { double basic_distance=velocity.mag()*consts::basic_tick; - if (targetLocation) { - double distance=coordinates.distance(targetLocation); + const Vector3D & target = collPos ? collPos : targetPos; + if (target) { + double distance=coordinates.distance(target); debug( cout << "basic_distance: " << basic_distance << endl << flush;); debug( cout << "distance: " << distance << endl << flush;); if (basic_distance>distance) { @@ -75,7 +76,7 @@ Move * Pedestrian::genMoveOperation(Location * rloc) Move * Pedestrian::genMoveOperation(Location * rloc, const Location & loc) { debug( cout << "genMoveOperation: status: Pedestrian(" << serialno - << "," << targetLocation << "," << velocity << "," + << "," << collPos << "," << targetPos << "," << velocity << "," << lastMovementTime << ")" << endl << flush;); if (updateNeeded(loc)) { debug(cout << "genMoveOperation: Update needed..." << endl << flush;); @@ -134,41 +135,47 @@ Move * Pedestrian::genMoveOperation(Location * rloc, const Location & loc) // Update location Vector3D new_coords; - if (updatedLocation) { - new_coords=updatedLocation+(velocity*time_diff); + if (updatedPos) { + new_coords=updatedPos+(velocity*time_diff); } else { new_coords=loc.coords+(velocity*time_diff); } - if (targetLocation) { + const Vector3D & target = collPos ? collPos : targetPos; + if (target) { Vector3D new_coords2 = new_coords+velocity/consts::basic_tick/10.0; - double dist=targetLocation.distance(new_coords); - double dist2=targetLocation.distance(new_coords2); + double dist=target.distance(new_coords); + double dist2=target.distance(new_coords2); debug( cout << "dist: " << dist << "," << dist2 << endl << flush;); if (dist2>dist) { debug( cout << "target achieved";); - new_coords=targetLocation; - if (targetRef != NULL) { - cout << "CONTACT " << targetRef->fullid << endl << flush; - if (targetRef == new_loc.ref->location.ref) { - cout << "OUT" << targetLocation << new_loc.ref->location.coords << endl << flush; - new_coords=targetLocation+new_loc.ref->location.coords; + new_coords=target; + if (collRef != NULL) { + cout << "CONTACT " << collRef->fullid << endl << flush; + if (collRef == new_loc.ref->location.ref) { + cout << "OUT" << target << new_loc.ref->location.coords << endl << flush; + new_coords=target + new_loc.ref->location.coords; } else { cout << "IN" << endl << flush; - new_coords=targetLocation-targetRef->location.coords; + new_coords=target - collRef->location.coords; } - new_loc.ref = targetRef; - targetRef = NULL; - // This needs to be the previously stored target location - targetLocation = Vector3D(); + new_loc.ref = collRef; + collRef = NULL; + // Transform targetPos to new ref? + collPos = Vector3D(); } else { - reset(); - entmap["mode"] = Object("standing"); + if (collPos) { + velocity[collAxis] = 0; + collPos = Vector3D(); + } else { + reset(); + entmap["mode"] = Object("standing"); + } new_loc.velocity=velocity; } } } new_loc.coords = new_coords; - updatedLocation = new_coords; + updatedPos = new_coords; // Check for collisions checkCollisions(new_loc); diff --git a/rulesets/Pedestrian.h b/rulesets/Pedestrian.h index 5959ca4e7..5dad07e9d 100644 --- a/rulesets/Pedestrian.h +++ b/rulesets/Pedestrian.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef PEDESTRIAN_H #define PEDESTRIAN_H @@ -23,4 +23,4 @@ class Pedestrian : public Movement { Move * genMoveOperation(Location *); }; -#endif /* PEDESTRIAN_H */ +#endif // PEDESTRIAN_H diff --git a/rulesets/Plant.cpp b/rulesets/Plant.cpp index 1ec48ce6e..f7fb5eb0f 100644 --- a/rulesets/Plant.cpp +++ b/rulesets/Plant.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -25,6 +25,10 @@ Plant::Plant() : fruits(0), radius(1), fruitName("seed") location.bmedian = Vector3D(0, 0, 0.5); } +Plant::~Plant() +{ +} + const Object & Plant::operator[](const string & aname) { if (aname == "fruits") { diff --git a/rulesets/Plant.h b/rulesets/Plant.h index 628a0c839..90bb9b862 100644 --- a/rulesets/Plant.h +++ b/rulesets/Plant.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef PLANT_H #define PLANT_H @@ -28,7 +28,7 @@ class Plant : public Thing { public: Plant(); - virtual ~Plant() { } + virtual ~Plant(); virtual const Object & operator[](const string & aname); virtual void set(const string & aname, const Object & attr); diff --git a/rulesets/PlantFactory.cpp b/rulesets/PlantFactory.cpp index 3f17a8a36..059951d13 100644 --- a/rulesets/PlantFactory.cpp +++ b/rulesets/PlantFactory.cpp @@ -1,16 +1,10 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch - -#include -#include -#include +// Copyright (C) 2000,2001 Alistair Riddoch #include "Plant.h" #include "PlantFactory.h" -PlantFactory * PlantFactory::m_instance = NULL; - Plant * PlantFactory::newThing() { return new Plant(); diff --git a/rulesets/PlantFactory.h b/rulesets/PlantFactory.h index ef69911f6..8bd865af1 100644 --- a/rulesets/PlantFactory.h +++ b/rulesets/PlantFactory.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef PLANT_FACTORY_H #define PLANT_FACTORY_H @@ -9,17 +9,9 @@ #include "Plant.h" class PlantFactory : public ThingFactory { - protected: - PlantFactory() { } - static PlantFactory * m_instance; public: - static PlantFactory * instance() { - if (m_instance == NULL) { - m_instance = new PlantFactory(); - } - return m_instance; - } + PlantFactory() { } virtual Plant * newThing(); }; -#endif /* PLANT_FACTORY_H */ +#endif // PLANT_FACTORY_H diff --git a/rulesets/Py_Location.h b/rulesets/Py_Location.h index fc89b9951..d71868167 100644 --- a/rulesets/Py_Location.h +++ b/rulesets/Py_Location.h @@ -11,4 +11,4 @@ extern PyTypeObject Location_Type; LocationObject * newLocationObject(PyObject *); -#endif /* PY_LOCATION_H */ +#endif // PY_LOCATION_H diff --git a/rulesets/Py_Map.h b/rulesets/Py_Map.h index feb8fd95e..a7097c4f8 100644 --- a/rulesets/Py_Map.h +++ b/rulesets/Py_Map.h @@ -11,4 +11,4 @@ extern PyTypeObject Map_Type; MapObject * newMapObject(PyObject *); -#endif /* PY_MAP_H */ +#endif // PY_MAP_H diff --git a/rulesets/Py_Object.cpp b/rulesets/Py_Object.cpp index c42b26a25..7a2f78245 100644 --- a/rulesets/Py_Object.cpp +++ b/rulesets/Py_Object.cpp @@ -57,8 +57,9 @@ static PyObject * Object_getattr(AtlasObject *self, char *name) } if (self->m_obj->IsMap()) { Object::MapType & omap = self->m_obj->AsMap(); - if (omap.find(name) != omap.end()) { - return Object_asPyObject(omap[name]); + Object::MapType::iterator I = omap.find(name); + if (I != omap.end()) { + return Object_asPyObject(I->second); } } if (self->Object_attr != NULL) { diff --git a/rulesets/Py_Object.h b/rulesets/Py_Object.h index b4c568e47..39dd9ad59 100644 --- a/rulesets/Py_Object.h +++ b/rulesets/Py_Object.h @@ -9,15 +9,15 @@ extern PyTypeObject Object_Type; #define PyAtlasObject_Check(_o) ((PyTypeObject*)PyObject_Type((PyObject*)_o)==&Object_Type) -/* - * Object creation function. - */ +// +// Object creation function. +// AtlasObject * newAtlasObject(PyObject *arg); -/* - * Utility functions to munge between Object related types and python types - */ +// +// Utility functions to munge between Object related types and python types +// // PyObject * MapType_asPyObject(const Object::MapType & map); // PyObject * ListType_asPyObject(const Object::ListType & list); diff --git a/rulesets/Py_Operation.cpp b/rulesets/Py_Operation.cpp index 0da299e29..1ba519e06 100644 --- a/rulesets/Py_Operation.cpp +++ b/rulesets/Py_Operation.cpp @@ -486,13 +486,27 @@ static PySequenceMethods Operation_seq = { * */ -// At the moment it looks as though only one set of methods will be required -// as they can all use it together -ATLAS_OPERATION_METHODS(RootOperation) -//ATLAS_OPERATION_METHODS(Login) -//ATLAS_OPERATION_METHODS(Create) -//ATLAS_OPERATION_METHODS(Move) -//ATLAS_OPERATION_METHODS(Set) +PyMethodDef RootOperation_methods[] = { + {"SetSerialno", (PyCFunction)Operation_SetSerialno, METH_VARARGS}, + {"SetRefno", (PyCFunction)Operation_SetRefno, METH_VARARGS}, + {"SetFrom", (PyCFunction)Operation_SetFrom, METH_VARARGS}, + {"SetTo", (PyCFunction)Operation_SetTo, METH_VARARGS}, + {"SetSeconds", (PyCFunction)Operation_SetSeconds, METH_VARARGS}, + {"SetFutureSeconds",(PyCFunction)Operation_SetFutureSeconds,METH_VARARGS}, + {"SetTimeString", (PyCFunction)Operation_SetTimeString, METH_VARARGS}, + {"SetArgs", (PyCFunction)Operation_SetArgs, METH_VARARGS}, + {"GetSerialno", (PyCFunction)Operation_GetSerialno, METH_VARARGS}, + {"GetRefno", (PyCFunction)Operation_GetRefno, METH_VARARGS}, + {"GetFrom", (PyCFunction)Operation_GetFrom, METH_VARARGS}, + {"GetTo", (PyCFunction)Operation_GetTo, METH_VARARGS}, + {"GetSeconds", (PyCFunction)Operation_GetSeconds, METH_VARARGS}, + {"GetFutureSeconds",(PyCFunction)Operation_GetFutureSeconds,METH_VARARGS}, + {"GetTimeString", (PyCFunction)Operation_GetTimeString, METH_VARARGS}, + {"GetArgs", (PyCFunction)Operation_GetArgs, METH_VARARGS}, + {"get_name", (PyCFunction)Operation_get_name, METH_VARARGS}, + {NULL, NULL} +}; + /* * Beginning of Operation standard methods section. @@ -597,7 +611,24 @@ static int Operation_setattr(RootOperationObject *self, char *name, PyObject *v) return 0; } -ATLAS_OPERATION_TYPE(RootOperation) +PyTypeObject RootOperation_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, // ob_size + "Operation", // tp_name + sizeof(RootOperationObject), // tp_basicsize + 0, // tp_itemsize + // methods + (destructor)Operation_dealloc, // tp_dealloc + 0, // tp_print + (getattrfunc)Operation_getattr, // tp_getattr + (setattrfunc)Operation_setattr, // tp_setattr + 0, // tp_compare + 0, // tp_repr + &Operation_num, // tp_as_number + &Operation_seq, // tp_as_sequence + 0, // tp_as_mapping + 0, // tp_hash +}; /* * Beginning of Operation creation functions section. diff --git a/rulesets/Py_Operation.h b/rulesets/Py_Operation.h index ccc3c4e33..d705ed826 100644 --- a/rulesets/Py_Operation.h +++ b/rulesets/Py_Operation.h @@ -11,4 +11,4 @@ extern PyTypeObject RootOperation_Type; RootOperationObject * newAtlasRootOperation(PyObject *arg); -#endif /* PY_OPERATION_H */ +#endif // PY_OPERATION_H diff --git a/rulesets/Py_Oplist.h b/rulesets/Py_Oplist.h index 529741ecd..d4c195bf3 100644 --- a/rulesets/Py_Oplist.h +++ b/rulesets/Py_Oplist.h @@ -11,4 +11,4 @@ extern PyTypeObject Oplist_Type; OplistObject * newOplistObject(PyObject *); -#endif /* PY_VECTOR3D_H */ +#endif // PY_VECTOR3D_H diff --git a/rulesets/Py_Optime.h b/rulesets/Py_Optime.h index b52b3c66f..52832b107 100644 --- a/rulesets/Py_Optime.h +++ b/rulesets/Py_Optime.h @@ -11,4 +11,4 @@ extern PyTypeObject Optime_Type; OptimeObject * newOptimeObject(PyObject *); -#endif /* PY_OPTIME_H */ +#endif // PY_OPTIME_H diff --git a/rulesets/Py_Thing.h b/rulesets/Py_Thing.h index 945a7c6fe..5a26dfbb1 100644 --- a/rulesets/Py_Thing.h +++ b/rulesets/Py_Thing.h @@ -11,4 +11,4 @@ extern PyTypeObject Thing_Type; ThingObject * newThingObject(PyObject *); -#endif /* PY_THING_H */ +#endif // PY_THING_H diff --git a/rulesets/Py_Vector3D.h b/rulesets/Py_Vector3D.h index 60fa96408..709a167e3 100644 --- a/rulesets/Py_Vector3D.h +++ b/rulesets/Py_Vector3D.h @@ -11,4 +11,4 @@ extern PyTypeObject Vector3D_Type; Vector3DObject * newVector3DObject(PyObject *); -#endif /* PY_VECTOR3D_H */ +#endif // PY_VECTOR3D_H diff --git a/rulesets/Py_World.h b/rulesets/Py_World.h index 6312b142b..e98e5a6af 100644 --- a/rulesets/Py_World.h +++ b/rulesets/Py_World.h @@ -11,4 +11,4 @@ extern PyTypeObject World_Type; WorldObject * newWorldObject(PyObject *); -#endif /* PY_WORLD_H */ +#endif // PY_WORLD_H diff --git a/rulesets/Py_WorldTime.h b/rulesets/Py_WorldTime.h index e927f921c..d060800e3 100644 --- a/rulesets/Py_WorldTime.h +++ b/rulesets/Py_WorldTime.h @@ -11,4 +11,4 @@ extern PyTypeObject WorldTime_Type; WorldTimeObject * newWorldTimeObject(PyObject *); -#endif /* PY_WORLDTIME_H */ +#endif // PY_WORLDTIME_H diff --git a/rulesets/PythonMindScript.cpp b/rulesets/PythonMindScript.cpp index 53b0035c8..505dda8a5 100644 --- a/rulesets/PythonMindScript.cpp +++ b/rulesets/PythonMindScript.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include "PythonMindScript.h" diff --git a/rulesets/PythonMindScript.h b/rulesets/PythonMindScript.h index afb8b02e5..d7538b5fe 100644 --- a/rulesets/PythonMindScript.h +++ b/rulesets/PythonMindScript.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef PYTHON_MIND_SCRIPT_H #define PYTHON_MIND_SCRIPT_H diff --git a/rulesets/PythonScript.cpp b/rulesets/PythonScript.cpp index 38df4de44..ec4a74611 100644 --- a/rulesets/PythonScript.cpp +++ b/rulesets/PythonScript.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include "PythonScript.h" diff --git a/rulesets/PythonScript.h b/rulesets/PythonScript.h index 2fded2638..5bd2329b3 100644 --- a/rulesets/PythonScript.h +++ b/rulesets/PythonScript.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef PYTHON_SCRIPT_H #define PYTHON_SCRIPT_H diff --git a/rulesets/PythonThingScript.cpp b/rulesets/PythonThingScript.cpp index f36716438..f5707997a 100644 --- a/rulesets/PythonThingScript.cpp +++ b/rulesets/PythonThingScript.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include "PythonThingScript.h" diff --git a/rulesets/PythonThingScript.h b/rulesets/PythonThingScript.h index 947f691cb..0ca99ea5c 100644 --- a/rulesets/PythonThingScript.h +++ b/rulesets/PythonThingScript.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef PYTHON_THING_SCRIPT_H #define PYTHON_THING_SCRIPT_H diff --git a/rulesets/Python_API.cpp b/rulesets/Python_API.cpp index 4a85697b3..15e78735a 100644 --- a/rulesets/Python_API.cpp +++ b/rulesets/Python_API.cpp @@ -13,7 +13,12 @@ #include "Thing.h" #include "BaseMind.h" +#include +#include +#include +#include #include +#include #include #include @@ -267,14 +272,14 @@ static PyObject * location_new(PyObject * self, PyObject * args) return NULL; } - BaseEntity * ref_ent; + Entity * ref_ent; if (PyWorld_Check(refO)) { WorldObject * ref = (WorldObject*)refO; if (ref->world == NULL) { PyErr_SetString(PyExc_TypeError, "Parent world is invalid"); return NULL; } - ref_ent = (BaseEntity *)ref->world; + ref_ent = (Entity *)ref->world; } else { ThingObject * ref = (ThingObject*)refO; if (ref->m_thing == NULL) { diff --git a/rulesets/Python_API.h b/rulesets/Python_API.h index a71e3b0e8..b2906a716 100644 --- a/rulesets/Python_API.h +++ b/rulesets/Python_API.h @@ -1,26 +1,10 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef PYTHON_API_H #define PYTHON_API_H -#include -#include -#include -#include -#include -#include -#include -#include - -using Atlas::Message::Object; -using Atlas::Objects::Operation::RootOperation; -//using Atlas::Objects::Operation::Login; -//using Atlas::Objects::Operation::Create; -//using Atlas::Objects::Operation::Move; -//using Atlas::Objects::Operation::Set; - class Entity; class Thing; class BaseMind; @@ -29,23 +13,24 @@ class Location; class WorldTime; class WorldRouter; -#include - -typedef std::vector oplist; +#include +#include #include #include +using Atlas::Message::Object; + typedef struct { PyObject_HEAD - PyObject * Object_attr; /* Attributes dictionary */ + PyObject * Object_attr; // Attributes dictionary Object * m_obj; } AtlasObject; typedef struct { PyObject_HEAD - PyObject * Thing_attr; /* Attributes dictionary */ + PyObject * Thing_attr; // Attributes dictionary Entity * m_thing; } ThingObject; @@ -75,14 +60,14 @@ typedef struct { WorldRouter * world; } WorldObject; -#define ATLAS_OPERATION(_name) typedef struct { \ - PyObject_HEAD \ - PyObject * Operation_attr; \ - _name * operation; \ - int own; \ - Entity * from; \ - Entity * to; \ -} _name ## Object; +typedef struct { + PyObject_HEAD + PyObject * Operation_attr; + RootOperation * operation; + int own; + Entity * from; + Entity * to; +} RootOperationObject; typedef struct { PyObject_HEAD @@ -98,50 +83,6 @@ typedef struct { RootOperation * operation; } OptimeObject; -#define ATLAS_OPERATION_METHODS(_name) \ -PyMethodDef _name ## _methods[] = { \ - {"SetSerialno", (PyCFunction)Operation_SetSerialno, METH_VARARGS}, \ - {"SetRefno", (PyCFunction)Operation_SetRefno, METH_VARARGS}, \ - {"SetFrom", (PyCFunction)Operation_SetFrom, METH_VARARGS}, \ - {"SetTo", (PyCFunction)Operation_SetTo, METH_VARARGS}, \ - {"SetSeconds", (PyCFunction)Operation_SetSeconds, METH_VARARGS}, \ - {"SetFutureSeconds",(PyCFunction)Operation_SetFutureSeconds,METH_VARARGS}, \ - {"SetTimeString", (PyCFunction)Operation_SetTimeString, METH_VARARGS}, \ - {"SetArgs", (PyCFunction)Operation_SetArgs, METH_VARARGS}, \ - {"GetSerialno", (PyCFunction)Operation_GetSerialno, METH_VARARGS}, \ - {"GetRefno", (PyCFunction)Operation_GetRefno, METH_VARARGS}, \ - {"GetFrom", (PyCFunction)Operation_GetFrom, METH_VARARGS}, \ - {"GetTo", (PyCFunction)Operation_GetTo, METH_VARARGS}, \ - {"GetSeconds", (PyCFunction)Operation_GetSeconds, METH_VARARGS}, \ - {"GetFutureSeconds",(PyCFunction)Operation_GetFutureSeconds,METH_VARARGS}, \ - {"GetTimeString", (PyCFunction)Operation_GetTimeString, METH_VARARGS}, \ - {"GetArgs", (PyCFunction)Operation_GetArgs, METH_VARARGS}, \ - {"get_name", (PyCFunction)Operation_get_name, METH_VARARGS}, \ -{NULL, NULL} \ -}; - -#define ATLAS_OPERATION_TYPE(_name) \ -PyTypeObject _name ## _Type = { \ - PyObject_HEAD_INIT(&PyType_Type) \ - 0, /*ob_size*/ \ - "Operation", /*tp_name*/ \ - sizeof(RootOperationObject), /*tp_basicsize*/ \ - 0, /*tp_itemsize*/ \ - /* methods */ \ - (destructor)Operation_dealloc, /*tp_dealloc*/ \ - 0, /*tp_print*/ \ - (getattrfunc)Operation_getattr, /*tp_getattr*/ \ - (setattrfunc)Operation_setattr, /*tp_setattr*/ \ - 0, /*tp_compare*/ \ - 0, /*tp_repr*/ \ - &Operation_num, /*tp_as_number*/ \ - &Operation_seq, /*tp_as_sequence*/ \ - 0, /*tp_as_mapping*/ \ - 0, /*tp_hash*/ \ -}; - -ATLAS_OPERATION(RootOperation) - #include "Py_Object.h" #include "Py_Thing.h" #include "Py_Map.h" @@ -156,4 +97,4 @@ ATLAS_OPERATION(RootOperation) void Create_PyThing(Thing * thing, const string& package, const string& type); void Create_PyMind(BaseMind * mind, const string& package, const string& type); -#endif /* PYTHON_API_H */ +#endif // PYTHON_API_H diff --git a/rulesets/Script.cpp b/rulesets/Script.cpp index 271bf7127..659b22ff1 100644 --- a/rulesets/Script.cpp +++ b/rulesets/Script.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include "Script.h" diff --git a/rulesets/Script.h b/rulesets/Script.h index 044c70fe4..4c0f98b28 100644 --- a/rulesets/Script.h +++ b/rulesets/Script.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef SCRIPT_H #define SCRIPT_H diff --git a/rulesets/StackFactory.cpp b/rulesets/StackFactory.cpp index 0a85da0ec..b0a18f93d 100644 --- a/rulesets/StackFactory.cpp +++ b/rulesets/StackFactory.cpp @@ -1,16 +1,10 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch - -#include -#include -#include +// Copyright (C) 2000,2001 Alistair Riddoch #include "Stackable.h" #include "StackFactory.h" -StackFactory * StackFactory::m_instance = NULL; - Stackable * StackFactory::newThing() { return new Stackable(); diff --git a/rulesets/StackFactory.h b/rulesets/StackFactory.h index 7023cc7a2..1b5256bd9 100644 --- a/rulesets/StackFactory.h +++ b/rulesets/StackFactory.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef STACK_FACTORY_H #define STACK_FACTORY_H @@ -9,17 +9,9 @@ #include "Stackable.h" class StackFactory : public ThingFactory { - protected: - StackFactory() { } - static StackFactory * m_instance; public: - static StackFactory * instance() { - if (m_instance == NULL) { - m_instance = new StackFactory(); - } - return m_instance; - } + StackFactory() { } virtual Stackable * newThing(); }; -#endif /* STACK_FACTORY_H */ +#endif // STACK_FACTORY_H diff --git a/rulesets/Stackable.cpp b/rulesets/Stackable.cpp index 071787a5c..ca35114ab 100644 --- a/rulesets/Stackable.cpp +++ b/rulesets/Stackable.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -23,6 +23,10 @@ Stackable::Stackable() : num(1) { } +Stackable::~Stackable() +{ +} + const Object & Stackable::operator[](const string & aname) { if (aname == "num") { @@ -55,12 +59,11 @@ oplist Stackable::Operation(const Combine & op) if (script->Operation("combine", op, res) != 0) { return(res); } - Object::ListType args = op.GetArgs(); - for(Object::ListType::iterator I = args.begin(); I != args.end(); I++) { - const string & id = I->AsMap()["id"].AsString(); + const Object::ListType & args = op.GetArgs(); + for(Object::ListType::const_iterator I= args.begin(); I!= args.end(); I++) { + const string & id = I->AsMap().find("id")->second.AsString(); if (id == fullid) { continue; } Stackable * obj = (Stackable*)world->getObject(id); - if (!obj->inGame) { continue; } if (obj->type != type) { continue; } num = num + obj->num; @@ -81,12 +84,13 @@ oplist Stackable::Operation(const Divide & op) if (script->Operation("divide", op, res) != 0) { return(res); } - Object::ListType args = op.GetArgs(); - for(Object::ListType::iterator I = args.begin(); I != args.end(); I++) { - Object::MapType & ent = I->AsMap(); + const Object::ListType & args = op.GetArgs(); + for(Object::ListType::const_iterator I= args.begin(); I!= args.end(); I++) { + const Object::MapType & ent = I->AsMap(); int new_num = 1; - if (ent.find("num") != ent.end()) { - if (ent["num"].IsInt()) { new_num = ent["num"].AsInt(); } + Object::MapType::const_iterator J = ent.find("num"); + if (J != ent.end()) { + if (J->second.IsInt()) { new_num = J->second.AsInt(); } } if (num <= new_num) { continue; } diff --git a/rulesets/Stackable.h b/rulesets/Stackable.h index 00531012d..6482cc8be 100644 --- a/rulesets/Stackable.h +++ b/rulesets/Stackable.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef STACKABLE_H #define STACKABLE_H @@ -20,7 +20,7 @@ class Stackable : public Thing { public: Stackable(); - virtual ~Stackable() { } + virtual ~Stackable(); virtual const Atlas::Message::Object & operator[](const string & aname); virtual void set(const string & aname, const Atlas::Message::Object & attr); diff --git a/rulesets/StructFactory.cpp b/rulesets/StructFactory.cpp index 320043d6a..3ca613d66 100644 --- a/rulesets/StructFactory.cpp +++ b/rulesets/StructFactory.cpp @@ -1,16 +1,10 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch - -#include -#include -#include +// Copyright (C) 2000,2001 Alistair Riddoch #include "Structure.h" #include "StructFactory.h" -StructureFactory * StructureFactory::m_instance = NULL; - Structure * StructureFactory::newThing() { return new Structure(); diff --git a/rulesets/StructFactory.h b/rulesets/StructFactory.h index de42755d6..7859b4fb8 100644 --- a/rulesets/StructFactory.h +++ b/rulesets/StructFactory.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef STRUCT_FACTORY_H #define STRUCT_FACTORY_H @@ -9,17 +9,9 @@ #include "Structure.h" class StructureFactory : public ThingFactory { - protected: - StructureFactory() { } - static StructureFactory * m_instance; public: - static StructureFactory * instance() { - if (m_instance == NULL) { - m_instance = new StructureFactory(); - } - return m_instance; - } + StructureFactory() { } virtual Structure * newThing(); }; -#endif /* STRUCT_FACTORY_H */ +#endif // STRUCT_FACTORY_H diff --git a/rulesets/Structure.h b/rulesets/Structure.h index 5af654227..c3d623073 100644 --- a/rulesets/Structure.h +++ b/rulesets/Structure.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #ifndef STRUCTURE_H #define STRUCTURE_H diff --git a/rulesets/Thing.cpp b/rulesets/Thing.cpp index c0d086ec6..15dd600d3 100644 --- a/rulesets/Thing.cpp +++ b/rulesets/Thing.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -26,7 +26,6 @@ #include "Thing.h" #include "Script.h" -#include "Python_API.h" #include @@ -46,17 +45,6 @@ Thing::Thing() : perceptive(false) Thing::~Thing() { } -void Thing::addToObject(Object & obj) const -{ - Object::MapType & omap = obj.AsMap(); - omap["name"] = Object(name); - omap["type"] = Object(type); - omap["parents"] = Object(Object::ListType(1,Object(type))); - // We need to have a list of keys to pull from attributes. - location.addToObject(obj); - BaseEntity::addToObject(obj); -} - oplist Thing::Operation(const Setup & op) { oplist res; @@ -79,11 +67,12 @@ oplist Thing::Operation(const Create & op) return oplist(); } try { - Object::MapType ent = args.front().AsMap(); - if (ent.find("parents") == ent.end()) { + const Object::MapType & ent = args.front().AsMap(); + Object::MapType::const_iterator I = ent.find("parents"); + if (I == ent.end()) { return error(op, "Object to be created has no type"); } - Object::ListType & parents = ent["parents"].AsList(); + const Object::ListType & parents = I->second.AsList(); string type; if (parents.size() < 1) { type = "thing"; @@ -93,8 +82,8 @@ oplist Thing::Operation(const Create & op) debug( cout << fullid << " creating " << type;); Thing * obj = world->addObject(type,ent); if (!obj->location) { - obj->location=location; - obj->location.velocity=Vector3D(0,0,0); + obj->location.ref = location.ref; + obj->location.coords = location.coords; } if (obj->location.ref != NULL) { obj->location.ref->contains.push_back(obj); @@ -134,18 +123,19 @@ oplist Thing::Operation(const Fire & op) if (script->Operation("fire", op, res) != 0) { return(res); } - if (attributes.find("burn_speed") == attributes.end()) { + Object::MapType::iterator I = attributes.find("burn_speed"); + if (I == attributes.end()) { return res; } - const Object & bs = attributes["burn_speed"]; + const Object & bs = I->second; if (!bs.IsNum()) { return res; } - Object::MapType fire_ent = op.GetArgs().front().AsMap(); - double consumed = bs.AsNum() * fire_ent["status"].AsNum(); + const Object::MapType & fire_ent = op.GetArgs().front().AsMap(); + double consumed = bs.AsNum() * fire_ent.find("status")->second.AsNum(); Object::MapType self_ent; self_ent["id"] = fullid; self_ent["status"] = status - (consumed / weight); - const string & to = fire_ent["id"].AsString(); + const string & to = fire_ent.find("id")->second.AsString(); Object::MapType nour_ent; nour_ent["id"] = to; nour_ent["weight"] = consumed; @@ -177,74 +167,45 @@ oplist Thing::Operation(const Move & op) debug( cout << "ERROR: move op has no argument" << endl << flush;); return oplist(); } - BaseEntity * newref; try { Vector3D oldpos = location.coords; - Object::MapType ent = args.front().AsMap(); - string & oname = ent["id"].AsString(); + const Object::MapType & ent = args.front().AsMap(); + const string & oname = ent.find("id")->second.AsString(); debug( cout << "In " << fullid << " got moveop for " << oname << endl << flush;); cout << "In " << fullid << " got moveop for " << oname << endl << flush; - if (ent.find("loc") == ent.end()) { + Object::MapType::const_iterator I = ent.find("loc"); + if (I == ent.end()) { debug( cout << "ERROR: move op arg has no ref" << endl << flush;); return(error(op, "Move location has no ref")); } - string ref=ent["loc"].AsString(); - if (ref == fullid) { - debug( cout << "ERROR: move op arg ref is same as entity" << endl << flush;); - debug( cout << "ERROR: attempt by entity to move into itself" << endl << flush;); - return error(op, "Attempt by entity to move into itself"); - } - if (world->objects.find(ref) == world->objects.end()) { + const string & ref = I->second.AsString(); + edict_t::iterator J = world->eobjects.find(ref); + if (J == world->eobjects.end()) { debug( cout << "ERROR: move op arg ref is invalid" << endl << flush;); return(error(op, "Move location ref invalid")); } cout << "{" << ref << "}" << endl << flush; - newref = world->objects[ref]; + Entity * newref = J->second; + if (newref == this) { + debug( cout << "ERROR: move op arg ref is same as entity" << endl << flush;); + debug( cout << "ERROR: attempt by entity to move into itself" << endl << flush;); + return error(op, "Attempt by entity to move into itself"); + } if (location.ref != newref) { location.ref->contains.remove(this); newref->contains.push_back(this); + location.ref = newref; } - location.ref=newref; - if (ent.find("pos") == ent.end()) { + I = ent.find("pos"); + if (I == ent.end()) { return(error(op, "Move location has no position")); } - Object::ListType vector = ent["pos"].AsList(); - if (vector.size()!=3) { - return(error(op, "Move location pos is malformed")); + + location.coords = Vector3D(I->second.AsList()); + I = ent.find("velocity"); + if (I != ent.end()) { + location.velocity = Vector3D(I->second.AsList()); } - // FIXME - //double x = vector.front().AsFloat(); - //vector.pop_front(); - //double y = vector.front().AsFloat(); - //vector.pop_front(); - //double z = vector.front().AsFloat(); - double x = vector[0].AsFloat(); - double y = vector[1].AsFloat(); - double z = vector[2].AsFloat(); - debug( cout << "POS: " << x << " " << y << " " << z << endl << flush;); - cout << "POS: " << x << " " << y << " " << z << endl << flush; - location.coords = Vector3D(x, y, z); - if (ent.find("velocity") != ent.end()) { - vector.clear(); - vector = ent["velocity"].AsList(); - if (vector.size()!=3) { - cerr << "ERROR: Move location velocity is malformed"; - return(error(op, "Move location velocity is malformed")); - } - // FIXME - //x = vector.front().AsFloat(); - //vector.pop_front(); - //y = vector.front().AsFloat(); - //vector.pop_front(); - //z = vector.front().AsFloat(); - x = vector[0].AsFloat(); - y = vector[1].AsFloat(); - z = vector[2].AsFloat(); - debug( cout << "VEL: " << x << " " << y << " " << z << endl << flush;); - location.velocity = Vector3D(x, y, z); - } - debug( cout << "MOVE calculate vel=" << location.velocity - << " coord=" << location.coords;); double speed_ratio; if (!(location.velocity)) { @@ -260,7 +221,7 @@ oplist Thing::Operation(const Move & op) // modes, but this would probably be wasteful if (consts::enable_ranges && perceptive) { debug(cout << "testing range" << endl;); - list_t::const_iterator I = location.ref->contains.begin(); + elist_t::const_iterator I = location.ref->contains.begin(); Object::ListType appear, disappear; for(;I != location.ref->contains.end(); I++) { const bool wasInRange = (*I)->location.inRange(oldpos, consts::sight_range); @@ -345,19 +306,10 @@ oplist Thing::Operation(const Set & op) return oplist(); } try { - Object::MapType ent = args.front().AsMap(); + const Object::MapType & ent = args.front().AsMap(); Object::MapType::const_iterator I; for (I = ent.begin(); I != ent.end(); I++) { - if (I->first == "id") continue; - if (I->first == "status") { - if (I->second.IsInt()) { - status = (double)I->second.AsInt(); - } else { - status = I->second.AsFloat(); - } - } else { - attributes[I->first] = I->second; - } + set(I->first, I->second); } RootOperation * s = new Sight(Sight::Instantiate()); Object::ListType args2(1,op.AsObject()); diff --git a/rulesets/Thing.h b/rulesets/Thing.h index 52cf10e12..b9f03ebd8 100644 --- a/rulesets/Thing.h +++ b/rulesets/Thing.h @@ -1,23 +1,18 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef THING_H #define THING_H -#include - #include "Entity.h" #include -class Player; -class Routing; -class MemMap; - class Thing : public Entity { - public: + protected: bool perceptive; + public: Thing(); virtual ~Thing(); @@ -26,7 +21,6 @@ class Thing : public Entity { return world->message(*op, this); } - virtual void addToObject(Atlas::Message::Object &) const; virtual oplist Operation(const Setup & op); virtual oplist Operation(const Create & op); virtual oplist Operation(const Delete & op); @@ -36,4 +30,4 @@ class Thing : public Entity { virtual oplist Operation(const Look & op); }; -#endif /* THING_H */ +#endif // THING_H diff --git a/rulesets/ThingFactory.cpp b/rulesets/ThingFactory.cpp index b718a6554..4bb51c7e7 100644 --- a/rulesets/ThingFactory.cpp +++ b/rulesets/ThingFactory.cpp @@ -1,16 +1,10 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch - -#include -#include -#include +// Copyright (C) 2000,2001 Alistair Riddoch #include "Thing.h" #include "ThingFactory.h" -ThingFactory * ThingFactory::m_instance = NULL; - Thing * ThingFactory::newThing() { return new Thing(); diff --git a/rulesets/ThingFactory.h b/rulesets/ThingFactory.h index 3930f7ae5..7ef0a3566 100644 --- a/rulesets/ThingFactory.h +++ b/rulesets/ThingFactory.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef THING_FACTORY_H #define THING_FACTORY_H @@ -8,17 +8,9 @@ #include "Thing.h" class ThingFactory { - protected: - ThingFactory() { } - static ThingFactory * m_instance; public: - static ThingFactory * instance() { - if (m_instance == NULL) { - m_instance = new ThingFactory(); - } - return m_instance; - } + ThingFactory() { } virtual Thing * newThing(); }; -#endif /* THING_FACTORY_H */ +#endif // THING_FACTORY_H diff --git a/rulesets/ThingShape.h b/rulesets/ThingShape.h index c48bd52af..94ab09740 100644 --- a/rulesets/ThingShape.h +++ b/rulesets/ThingShape.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef THING_SHAPE_H #define THING_SHAPE_H diff --git a/server/Account.cpp b/server/Account.cpp index 05202ecb4..a99b99846 100644 --- a/server/Account.cpp +++ b/server/Account.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -21,6 +21,7 @@ #include #include +#include #include #include "Account.h" @@ -33,7 +34,8 @@ using Atlas::Message::Object; using Atlas::Objects::Operation::Info; Account::Account(Connection* conn, const string& username, const string& passwd) - : connection(conn), password(passwd), type("account") + : world(NULL), connection(conn), password(passwd), + type("account") { fullid = username; } @@ -49,7 +51,7 @@ BaseEntity * Account::addCharacter(const string & typestr, const Object & ent) debug(cout << "Added" << endl << flush;); if (!chr->location) { debug(cout << "Setting location" << endl << flush;); - chr->location.ref = world; + chr->location.ref = &world->gameWorld; chr->location.coords = Vector3D(0, 0, 0); } debug(cout << "Location set to: " << chr->location << endl << flush;); @@ -77,7 +79,7 @@ BaseEntity * Account::addCharacter(const string & typestr, const Object & ent) oplist Account::Operation(const Logout & op) { - debug(cout << "Account logout: " << name << endl;); + debug(cout << "Account logout: " << fullid << endl;); connection->destroy(); return oplist(); } @@ -91,7 +93,7 @@ void Account::addToObject(Object & obj) const } omap["parents"] = Object(Object::ListType(1,Object(type))); Object::ListType charlist; - dict_t::const_iterator I; + edict_t::const_iterator I; for(I = charactersDict.begin(); I != charactersDict.end(); I++) { charlist.push_back(Object(I->first)); } @@ -107,19 +109,19 @@ oplist Account::Operation(const Create & op) if (!ent.IsMap()) { return(error(op, "Invalid character")); } - Object::MapType entmap = ent.AsMap(); - if ((entmap.find("parents")==entmap.end()) || - !(entmap["parents"].IsList()) || - (entmap["parents"].AsList().size()==0) || - !(entmap["parents"].AsList().front().IsString()) ) { + const Object::MapType & entmap = ent.AsMap(); + Object::MapType::const_iterator I = entmap.find("parents"); + if ((I == entmap.end()) || !(I->second.IsList()) || + (I->second.AsList().size()==0) || + !(I->second.AsList().front().IsString()) ) { return(error(op, "Character has no type")); } - oplist error = characterError(op, ent); + oplist error = characterError(op, entmap); if (error.size() != 0) { return(error); } - const string & typestr = entmap["parents"].AsList().front().AsString(); + const string & typestr = I->second.AsList().front().AsString(); debug(cout << "Account creating a " << typestr << " object" << endl << flush;); BaseEntity * obj = addCharacter(typestr, ent); diff --git a/server/Account.h b/server/Account.h index 58b049c1b..bfb96fb67 100644 --- a/server/Account.h +++ b/server/Account.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef ACCOUNT_H #define ACCOUNT_H @@ -9,15 +9,16 @@ class Connection; class WorldRouter; -class Thing; class Account : public OOGThing { friend class Connection; - dict_t charactersDict; + edict_t charactersDict; BaseEntity * addCharacter(const string &, const Atlas::Message::Object &); protected: - virtual oplist characterError(const Create &, const Atlas::Message::Object &) const = 0; + virtual oplist characterError(const Create &, const Atlas::Message::Object::MapType &) const = 0; + public: + WorldRouter * world; Connection * connection; string password; string type; @@ -30,4 +31,4 @@ class Account : public OOGThing { virtual oplist Operation(const Create & op); }; -#endif /* ACCOUNT_H */ +#endif // ACCOUNT_H diff --git a/server/Admin.cpp b/server/Admin.cpp index 3b6b8458f..bb350d096 100644 --- a/server/Admin.cpp +++ b/server/Admin.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -19,6 +19,7 @@ #include "ServerRouting.h" #include "WorldRouter.h" #include +#include using Atlas::Message::Object; using Atlas::Objects::Operation::Info; @@ -33,13 +34,13 @@ Admin::~Admin() { } -oplist Admin::characterError(const Create &, const Object &) const { +oplist Admin::characterError(const Create &, const Object::MapType &) const { return oplist(); } oplist Admin::Operation(const Save & op) { - dict_t::const_iterator I; + edict_t::const_iterator I; Persistance * p = Persistance::instance(); DatabaseIterator dbi(p->getWorld()); Object ent; @@ -47,7 +48,7 @@ oplist Admin::Operation(const Save & op) dbi.del(); } int count = 0; - for(I = world->objects.begin(); I != world->objects.end(); I++) { + for(I = world->eobjects.begin(); I != world->eobjects.end(); I++) { p->putEntity(I->second); ++count; } @@ -68,12 +69,12 @@ oplist Admin::Operation(const Load & op) DatabaseIterator dbi(p->getWorld()); Object ent; while (dbi.get(ent)) { - Object::MapType m = ent.AsMap(); - bool p = (m.find("parents") != m.end()); - const string & type = p ? m["parents"].AsList().front().AsString() - : "thing"; - if (m.find("id") != m.end()) { - const string & id = m["id"].AsString(); + const Object::MapType & m = ent.AsMap(); + Object::MapType::const_iterator I = m.find("parents"); + const string & type = (I != m.end()) ? I->second.AsList().front().AsString() : "thing"; + I = m.find("id"); + if (I != m.end()) { + const string & id = I->second.AsString(); if (id == "world_0") { // Ignore the world entry. No info required at the moment. } else { @@ -96,13 +97,14 @@ oplist Admin::Operation(const Get & op) { const Object & ent = op.GetArgs().front(); try { - Object::MapType emap = ent.AsMap(); - const string & id = emap["id"].AsString(); + const Object::MapType & emap = ent.AsMap(); + const string & id = emap.find("id")->second.AsString(); if (id == "server") { - const string & cmd = emap["cmd"].AsString(); + const string & cmd = emap.find("cmd")->second.AsString(); Object arg; - if (emap.find("arg") != emap.end()) { - arg = emap["arg"]; + Object::MapType::const_iterator I = emap.find("arg"); + if (I != emap.end()) { + arg = I->second; } if (cmd == "query") { if (!arg.IsString()) { @@ -136,13 +138,14 @@ oplist Admin::Operation(const Set & op) { const Object & ent = op.GetArgs().front(); try { - Object::MapType emap = ent.AsMap(); - const string & id = emap["id"].AsString(); + const Object::MapType & emap = ent.AsMap(); + const string & id = emap.find("id")->second.AsString(); if (id == "server") { - const string & cmd = emap["cmd"].AsString(); + const string & cmd = emap.find("cmd")->second.AsString(); Object arg; - if (emap.find("arg") != emap.end()) { - arg = emap["arg"]; + Object::MapType::const_iterator I = emap.find("arg"); + if (I != emap.end()) { + arg = I->second; } if (cmd == "shutdown") { exit_flag = true; diff --git a/server/Admin.h b/server/Admin.h index 7ef23edd1..cf02f9c85 100644 --- a/server/Admin.h +++ b/server/Admin.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef ADMIN_H #define ADMIN_H @@ -9,7 +9,7 @@ class Admin : public Account { protected: - virtual oplist characterError(const Create &, const Atlas::Message::Object &) const; + virtual oplist characterError(const Create &, const Atlas::Message::Object::MapType &) const; public: Admin(Connection * conn, const string & username, const string & passwd); virtual ~Admin(); @@ -20,4 +20,4 @@ class Admin : public Account { virtual oplist Operation(const Set & op); }; -#endif /* ADMIN_H */ +#endif // ADMIN_H diff --git a/server/CommClient.h b/server/CommClient.h index 5ce1b9020..432938c9f 100644 --- a/server/CommClient.h +++ b/server/CommClient.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMM_CLIENT_H #define COMM_CLIENT_H @@ -74,4 +74,4 @@ class CommClient : Atlas::Objects::Decoder { int setup(); }; -#endif /* COMM_CLIENT_H */ +#endif // COMM_CLIENT_H diff --git a/server/CommServer.h b/server/CommServer.h index 61379b4bf..0f476ec31 100644 --- a/server/CommServer.h +++ b/server/CommServer.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef COMM_SERVER_H #define COMM_SERVER_H diff --git a/server/Connection.cpp b/server/Connection.cpp index 793aa0be7..de1c6818f 100644 --- a/server/Connection.cpp +++ b/server/Connection.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -35,18 +35,25 @@ using Atlas::Message::Object; using Atlas::Objects::Operation::Info; Connection::Connection(CommClient & client) : commClient(client), - server(commClient.commServer.server) { } + server(commClient.commServer.server) +{ +} -void Connection::send(const RootOperation * msg) const { +Connection::~Connection() +{ +} + +void Connection::send(const RootOperation * msg) const +{ commClient.send(msg); } -Account * Connection::addPlayer(string & username, string & password) +Account * Connection::addPlayer(const string& username, const string& password) { Player * player=new Player(this, username, password); addObject(player); player->connection=this; - player->world=server.world; + player->world=&server.getWorld(); server.addObject(player); return(player); } @@ -63,6 +70,7 @@ void Connection::destroy() Thing * obj = (Thing*)ent; if (obj->isCharacter == true) { Character * character = (Character *)obj; + // FIXME Should do something to delete the external mind if (character->externalMind != NULL) { character->externalMind = NULL; } @@ -81,8 +89,9 @@ oplist Connection::operation(const RootOperation & op) } else { debug(cout << "Must send on to account" << endl << flush;); debug(cout << "[" << from << "]" << endl << flush;); - if (objects.find(from)!=objects.end()) { - BaseEntity * ent = objects[from]; + dict_t::const_iterator I = objects.find(from); + if (I != objects.end()) { + BaseEntity * ent = I->second; if ((ent->inGame != false)&&(((Thing *)ent)->isCharacter != 0) && (((Character *)ent)->externalMind == NULL)) { Character * pchar = (Character *)ent; @@ -111,20 +120,20 @@ oplist Connection::Operation(const Login & op) const Object & account = op.GetArgs().front(); if (account.IsMap()) { - string account_id = account.AsMap().find("id")->second.AsString(); - string password = account.AsMap().find("password")->second.AsString(); + const string account_id = account.AsMap().find("id")->second.AsString(); + const string password = account.AsMap().find("password")->second.AsString(); Account * player = (Player *)server.getObject(account_id); if (player == NULL) { player = Persistance::instance()->getAccount(account_id); if (player != NULL) { - player->world=server.world; + player->world=&server.getWorld(); server.addObject(player); } } if (player && (account_id.size()!=0) && (password==player->password)) { addObject(player); - dict_t::const_iterator I; + edict_t::const_iterator I; for (I=player->charactersDict.begin(); I!=player->charactersDict.end(); I++) { addObject(I->second); @@ -151,8 +160,8 @@ oplist Connection::Operation(const Create & op) } if (account.IsMap()) { - string account_id = account.AsMap().find("id")->second.AsString(); - string password = account.AsMap().find("password")->second.AsString(); + const string & account_id = account.AsMap().find("id")->second.AsString(); + const string & password = account.AsMap().find("password")->second.AsString(); if ((NULL==server.getObject(account_id)) && (!Persistance::instance()->findAccount(account_id)) && @@ -176,8 +185,8 @@ oplist Connection::Operation(const Logout & op) const Object & account = op.GetArgs().front(); if (account.IsMap()) { - string account_id = account.AsMap().find("id")->second.AsString(); - string password = account.AsMap().find("password")->second.AsString(); + const string & account_id = account.AsMap().find("id")->second.AsString(); + // const string & password = account.AsMap().find("password")->second.AsString(); Player * player = (Player *)server.getObject(account_id); if (player) { Logout l = op; diff --git a/server/Connection.h b/server/Connection.h index ecef5293d..ac1e894ad 100644 --- a/server/Connection.h +++ b/server/Connection.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef CONNECTION_H #define CONNECTION_H @@ -8,19 +8,18 @@ #include "Routing.h" class ServerRouting; -class Account; -class Player; class CommClient; +class Account; class Connection : public Routing { CommClient & commClient; ServerRouting & server; - Account * addPlayer(string &, string &); + Account * addPlayer(const string &, const string &); public: Connection(CommClient & client); - virtual ~Connection() { } + virtual ~Connection(); void destroy(); void send(const RootOperation * msg) const; @@ -32,4 +31,4 @@ class Connection : public Routing { virtual oplist Operation(const Get & op); }; -#endif /* CONNECTION_H */ +#endif // CONNECTION_H diff --git a/server/Connection_methods.h b/server/Connection_methods.h index 1bdae31be..f54daccf3 100644 --- a/server/Connection_methods.h +++ b/server/Connection_methods.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef CONNECTION_METHODS_H #define CONNECTION_METHODS_H diff --git a/server/Makefile.am b/server/Makefile.am index 9dad6fcd5..e57b68760 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -9,7 +9,6 @@ cyphesis_SOURCES = \ ServerRouting.cpp ServerRouting.h \ WorldRouter.cpp WorldRouter.h \ Connection.cpp Connection.h \ - WorldTime.cpp WorldTime.h \ CommClient.h CommServer.h \ server.cpp server.h diff --git a/server/OOG_Thing.cpp b/server/OOG_Thing.cpp index 7b86397ca..6607b90b7 100644 --- a/server/OOG_Thing.cpp +++ b/server/OOG_Thing.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -8,6 +8,10 @@ #include "OOG_Thing.h" +OOGThing::~OOGThing() +{ +} + oplist OOGThing::Operation(const RootOperation & op) { return(error(op, "Unknown operation")); } diff --git a/server/OOG_Thing.h b/server/OOG_Thing.h index bb7813d79..3ffeaf2c6 100644 --- a/server/OOG_Thing.h +++ b/server/OOG_Thing.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef OOG_THING_H #define OOG_THING_H @@ -10,8 +10,8 @@ class OOGThing : public BaseEntity { public: OOGThing() { } - virtual ~OOGThing() { } + virtual ~OOGThing(); virtual oplist Operation(const RootOperation & op); }; -#endif /* OOG_THING_H */ +#endif // OOG_THING_H diff --git a/server/Player.cpp b/server/Player.cpp index 40167409a..02a7870f3 100644 --- a/server/Player.cpp +++ b/server/Player.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -19,19 +19,18 @@ Player::Player(Connection* conn, const string& username, const string& passwd) : Player::~Player() { } -oplist Player::characterError(const Create & op, const Object & ent) const +oplist Player::characterError(const Create& op,const Object::MapType& ent) const { - Object::MapType entmap = ent.AsMap(); - - if ((entmap.find("name")==entmap.end()) || !entmap["name"].IsString()) { + Object::MapType::const_iterator I = ent.find("name"); + if ((I == ent.end()) || !I->second.IsString()) { return error(op, "Object to be created has no name"); } - if (!entmap["name"].AsString().compare("admin", 0, 5)) { + if (!I->second.AsString().compare("admin", 0, 5)) { return error(op, "Object to be created cannot start with admin"); } - const string & type = entmap["parents"].AsList().front().AsString(); + const string& type= ent.find("parents")->second.AsList().front().AsString(); if ((type!="character") && (type!="farmer") && (type!="smith")) { return error(op, "Object of that type cannot be created by this account"); diff --git a/server/Player.h b/server/Player.h index 5f0888837..d456b0a7a 100644 --- a/server/Player.h +++ b/server/Player.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef PLAYER_H #define PLAYER_H @@ -9,10 +9,10 @@ class Player : public Account { protected: - virtual oplist characterError(const Create & op, const Atlas::Message::Object & ent) const; + virtual oplist characterError(const Create & op, const Atlas::Message::Object::MapType & ent) const; public: Player(Connection * conn, const string & username, const string & passwd); virtual ~Player(); }; -#endif /* PLAYER_H */ +#endif // PLAYER_H diff --git a/server/Routing.cpp b/server/Routing.cpp index 00913a585..d44022454 100644 --- a/server/Routing.cpp +++ b/server/Routing.cpp @@ -1,9 +1,13 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include #include #include "Routing.h" + +Routing::~Routing() +{ +} diff --git a/server/Routing.h b/server/Routing.h index d87693ad1..4686bb856 100644 --- a/server/Routing.h +++ b/server/Routing.h @@ -1,20 +1,19 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef ROUTING_H #define ROUTING_H -#include - #include "OOG_Thing.h" class Routing : public OOGThing { -public: + protected: dict_t objects; + public: Routing() { } - ~Routing() { } + virtual ~Routing(); BaseEntity * addObject(BaseEntity * obj) { objects[obj->fullid]=obj; @@ -35,4 +34,4 @@ public: } }; -#endif /* ROUTING_H */ +#endif // ROUTING_H diff --git a/server/ServerRouting.cpp b/server/ServerRouting.cpp index 62b7bb127..0d20b7866 100644 --- a/server/ServerRouting.cpp +++ b/server/ServerRouting.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -8,19 +8,20 @@ #include "ServerRouting_methods.h" #include "CommServer.h" +#include "Account.h" #include +using Atlas::Message::Object; ServerRouting::ServerRouting(CommServer & server, const string & name) : - commServer(server), svrName(name) + commServer(server), svrName(name), world(*new WorldRouter(*this)) { fullid = name; idDict[fullid] = this; - world=new WorldRouter(*this); //game world; - BaseEntity * obj=addObject((BaseEntity*)Persistance::load_admin_account()); - //obj->server=this; - obj->world=world; + Account * adm = Persistance::load_admin_account(); + addObject(adm); + adm->world=&world; } ServerRouting::~ServerRouting() @@ -35,7 +36,7 @@ void ServerRouting::addToObject(Object & obj) const Object::ListType plist(1, "server"); omap["parents"] = plist; omap["clients"] = commServer.numClients(); - omap["uptime"] = world->upTime(); + omap["uptime"] = world.upTime(); if (Persistance::restricted) { omap["restricted"] = "true"; } diff --git a/server/ServerRouting.h b/server/ServerRouting.h index a44be2139..935bc6773 100644 --- a/server/ServerRouting.h +++ b/server/ServerRouting.h @@ -1,30 +1,33 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef SERVER_ROUTING_H #define SERVER_ROUTING_H -#include - #include "Routing.h" class WorldRouter; class CommServer; class ServerRouting : public Routing { + private: CommServer & commServer; const string svrName; public: dict_t idDict; - + private: + WorldRouter & world; + public: ServerRouting(CommServer & server, const string & name); ~ServerRouting(); int idle(); BaseEntity * addObject(BaseEntity * obj); + WorldRouter & getWorld() { return world; } + virtual void addToObject(Atlas::Message::Object &) const; }; -#endif /* SERVER_ROUTING_H */ +#endif // SERVER_ROUTING_H diff --git a/server/ServerRouting_methods.h b/server/ServerRouting_methods.h index f3eca8e7f..aab5a93a3 100644 --- a/server/ServerRouting_methods.h +++ b/server/ServerRouting_methods.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef SERVER_ROUTING_METHODS_H #define SERVER_ROUTING_METHODS_H @@ -9,7 +9,7 @@ #include "WorldRouter.h" inline int ServerRouting::idle() { - return world->idle(); + return world.idle(); } inline BaseEntity * ServerRouting::addObject(BaseEntity * obj) { diff --git a/server/WorldRouter.cpp b/server/WorldRouter.cpp index 5653fd569..fbcf81319 100644 --- a/server/WorldRouter.cpp +++ b/server/WorldRouter.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include @@ -14,6 +14,7 @@ #include "ServerRouting.h" #include +#include #include #include #include @@ -28,18 +29,26 @@ using Atlas::Message::Object; static const bool debug_flag = false; -WorldRouter::WorldRouter(ServerRouting & srvr) : server(srvr), nextId(0) +WorldRouter::WorldRouter(ServerRouting & srvr) : server(srvr), + gameWorld(*new World()), + nextId(0) { fullid = "world_0"; initTime = time(NULL); updateTime(); - server.idDict[fullid]=this; - objects[fullid]=this; - perceptives.push_back(this); - objectList.push_back(this); + gameWorld.fullid = fullid; + gameWorld.world=this; + server.idDict[fullid]=&gameWorld; + eobjects[fullid]=&gameWorld; + perceptives.push_back(&gameWorld); + objectList.push_back(&gameWorld); //WorldTime tmp_date("612-1-1 08:57:00"); } +WorldRouter::~WorldRouter() +{ +} + inline void WorldRouter::addOperationToQueue(RootOperation & op, const BaseEntity * obj) { @@ -98,18 +107,18 @@ Thing * WorldRouter::addObject(Thing * obj) } else { cout << "Adding object with known id" << endl << flush; } - server.idDict[obj->fullid]=objects[obj->fullid]=obj; + server.idDict[obj->fullid]=eobjects[obj->fullid]=obj; objectList.push_back(obj); if (!obj->location) { - debug(cout << "set loc " << this << endl << flush;); - obj->location.ref=this; + debug(cout << "set loc " << &gameWorld << endl << flush;); + obj->location.ref=&gameWorld; obj->location.coords=Vector3D(0,0,0); debug(cout << "loc set with ref " << obj->location.ref->fullid << endl << flush;); } - if (obj->location.ref==this) { + if (obj->location.ref==&gameWorld) { debug(cout << "loc is world" << endl << flush;); - contains.push_back(obj); - contains.unique(); + gameWorld.contains.push_back(obj); + gameWorld.contains.unique(); } obj->world=this; if (obj->omnipresent) { @@ -132,18 +141,18 @@ Thing * WorldRouter::addObject(const string & typestr, const Object & ent, return addObject(obj); } -void WorldRouter::delObject(BaseEntity * obj) +void WorldRouter::delObject(Entity * obj) { // Remove object from contains of its real ref? if (obj->location.ref != NULL) { obj->location.ref->contains.remove(obj); } // Remove object from world just to make sure - contains.remove(obj); + gameWorld.contains.remove(obj); omnipresentList.remove(obj); perceptives.remove(obj); objectList.remove(obj); - objects.erase(obj->fullid); + eobjects.erase(obj->fullid); } oplist WorldRouter::message(const RootOperation & op) @@ -154,13 +163,13 @@ oplist WorldRouter::message(const RootOperation & op) return oplist(); } -oplist WorldRouter::message(RootOperation & op, const BaseEntity * obj) +oplist WorldRouter::message(RootOperation & op, const Entity * obj) { addOperationToQueue(op, obj); return oplist(); } -inline const list_t & WorldRouter::broadcastList(const RootOperation & op) const +inline const elist_t& WorldRouter::broadcastList(const RootOperation & op) const { const Object::ListType & parents = op.GetParents(); if ((parents.size() > 0) && (parents.front().IsString())) { @@ -181,45 +190,40 @@ oplist WorldRouter::operation(const RootOperation * op) debug(cout << 0 << flush;); if ((to.size() != 0) && (to!="all")) { - if (objects.find(to) == objects.end()) { + edict_t::const_iterator I = eobjects.find(to); + if (I == eobjects.end()) { cerr << "CRITICAL: Op to=\"" << to << "\"" << " does not exist" << endl << flush; return oplist(); } - BaseEntity * to_entity = objects[to]; + Entity * to_entity = I->second; if (to_entity == NULL) { cerr << "CRITICAL: Op to=\"" << to << "\"" << " is NULL" << endl << flush; return oplist(); } - if ((to != fullid) || (op_type == OP_LOOK)) { - oplist res; - if (to == fullid) { - res = ((BaseEntity *)this)->Operation((Look &)op_ref); - } else { - res = to_entity->operation(op_ref); - } - for(oplist::const_iterator I = res.begin(); I != res.end(); I++) { - message(**I, to_entity); - } - if (op_type == OP_DELETE) { - delObject(to_entity); - to_entity->destroy(); - to_entity->deleted = true; - delete to_entity; - to_entity = NULL; - } + oplist res = to_entity->operation(op_ref); + for(oplist::const_iterator I = res.begin(); I != res.end(); I++) { + message(**I, to_entity); + } + if ((op_type == OP_DELETE) && (to_entity != &gameWorld)) { + delObject(to_entity); + to_entity->destroy(); + to_entity->deleted = true; + delete to_entity; + to_entity = NULL; } } else { RootOperation newop = op_ref; - const list_t & broadcast = broadcastList(op_ref); - std::list::const_iterator I; + const elist_t & broadcast = broadcastList(op_ref); + elist_t::const_iterator I; for(I = broadcast.begin(); I != broadcast.end(); I++) { if (consts::enable_ranges) { const string & from = newop.GetFrom(); + edict_t::const_iterator J = eobjects.find(from); if ((from.size() != 0) && - (objects.find(from) != objects.end()) && - (!objects[from]->location.inRange((*I)->location, + (J != eobjects.end()) && + (!J->second->location.inRange((*I)->location, consts::sight_range))) { debug(cout << "Op from " <fullid << endl << flush;); @@ -228,6 +232,8 @@ oplist WorldRouter::operation(const RootOperation * op) } } newop.SetTo((*I)->fullid); + // FIXME THere must be a more efficient way to deliver, with less + // chance of a loop. operation(&newop); } } @@ -240,27 +246,28 @@ oplist WorldRouter::operation(const RootOperation & op) return(operation(&op)); } -oplist WorldRouter::Operation(const Look & op) +oplist WorldRouter::lookOperation(const Look & op) { debug(cout << "WorldRouter::Operation(Look)" << endl << flush;); - string from = op.GetFrom(); - if (objects.find(from) == objects.end()) { + const string & from = op.GetFrom(); + edict_t::const_iterator J = eobjects.find(from); + if (J == eobjects.end()) { debug(cout << "FATAL: Op has invalid from" << endl << flush;); //return(*(RootOperation **)NULL); } else { debug(cout << "Adding [" << from << "] to perceptives" << endl << flush;); - perceptives.push_back(objects[from]); + perceptives.push_back(J->second); perceptives.unique(); if (consts::enable_ranges) { Sight * s = new Sight(Sight::Instantiate()); Object::MapType omap; omap["id"] = fullid; - BaseEntity * opFrom = objects[from]; + Entity * opFrom = J->second; const Vector3D & fromLoc = opFrom->getXyz(); Object::ListType contlist; - list_t::const_iterator I; - for(I = contains.begin(); I != contains.end(); I++) { + elist_t::const_iterator I; + for(I = gameWorld.contains.begin(); I != gameWorld.contains.end(); I++) { if ((*I)->location.inRange(fromLoc, consts::sight_range)) { contlist.push_back(Object((*I)->fullid)); } diff --git a/server/WorldRouter.h b/server/WorldRouter.h index f66b9ccdb..4311cdf0d 100644 --- a/server/WorldRouter.h +++ b/server/WorldRouter.h @@ -1,48 +1,58 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef WORLD_ROUTER_H #define WORLD_ROUTER_H -#include #include #include class WorldRouter; class ServerRouting; class Thing; +class Entity; +class World; -#include "Routing.h" +#include "OOG_Thing.h" -typedef std::list opqueue; - -class WorldRouter : public Routing { +class WorldRouter : public OOGThing { double realTime; opqueue operationQueue; - list_t objectList; + elist_t objectList; time_t initTime; void addOperationToQueue(RootOperation & op, const BaseEntity *); RootOperation * getOperationFromQueue(); string getId(string & name); - const list_t & broadcastList(const RootOperation & op) const; + const elist_t & broadcastList(const RootOperation & op) const; oplist operation(const RootOperation * op); public: ServerRouting & server; + World & gameWorld; int nextId; - list_t perceptives; - list_t omnipresentList; + elist_t perceptives; + elist_t omnipresentList; + edict_t eobjects; WorldRouter(ServerRouting & server); - virtual ~WorldRouter() { } + virtual ~WorldRouter(); int idle(); Thing * addObject(Thing * obj); Thing * addObject(const string &, const Atlas::Message::Object &, const string & id = string()); - void delObject(BaseEntity * obj); + void delObject(Entity * obj); + + Entity * getObject(const string & fid) { + return eobjects[fid]; + } + + Entity * findObject(const string & fid) { + return eobjects[fid]; + } + void updateTime() { struct timeval tv; @@ -59,10 +69,11 @@ class WorldRouter : public Routing { return realTime; } - virtual oplist message(RootOperation & op, const BaseEntity * obj); + virtual oplist message(RootOperation & op, const Entity * obj); virtual oplist message(const RootOperation & op); virtual oplist operation(const RootOperation & op); - virtual oplist Operation(const Look & op); + + oplist lookOperation(const Look & op); }; -#endif /* WORLD_ROUTER_H */ +#endif // WORLD_ROUTER_H diff --git a/server/WorldTime.cpp b/server/WorldTime.cpp index e25d17bfd..a69b6b590 100644 --- a/server/WorldTime.cpp +++ b/server/WorldTime.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include diff --git a/server/WorldTime.h b/server/WorldTime.h index b7e16c7a5..eddc461bd 100644 --- a/server/WorldTime.h +++ b/server/WorldTime.h @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef WORLD_TIME_H #define WORLD_TIME_H @@ -44,4 +44,4 @@ class WorldTime { const string & seconds2string(double seconds); -#endif /* WORLD_TIME_H */ +#endif // WORLD_TIME_H diff --git a/server/server.cpp b/server/server.cpp index 76ed33cf8..865040153 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #include #include diff --git a/server/server.h b/server/server.h index c766e9b00..3966a9f48 100644 --- a/server/server.h +++ b/server/server.h @@ -1,8 +1,8 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2000,2001 Alistair Riddoch #ifndef SERVER_H #define SERVER_H -#endif /* SERVER_H */ +#endif // SERVER_H diff --git a/tools/cycmd.cpp b/tools/cycmd.cpp index 21481c82d..c946f75d4 100644 --- a/tools/cycmd.cpp +++ b/tools/cycmd.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU Lesser General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include #include @@ -123,12 +123,12 @@ void Interactive::ObjectArrived(const Atlas::Objects::Operation::Error& o) reply_flag = true; error_flag = true; cout << "Error from server:" << endl << flush; - Object::ListType args = o.GetArgs(); - Object & arg = args.front(); + const Object::ListType & args = o.GetArgs(); + const Object & arg = args.front(); if (arg.IsString()) { cout << arg.AsString() << endl << flush; } else if (arg.IsMap()) { - cout << arg.AsMap()["message"].AsString() << endl << flush; + cout << arg.AsMap().find("message")->second.AsString() << endl << flush; } } diff --git a/tools/cydbload.cpp b/tools/cydbload.cpp index ab12d743a..e7b6f1f88 100644 --- a/tools/cydbload.cpp +++ b/tools/cydbload.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include #include @@ -44,14 +44,14 @@ class FileDecoder : public Atlas::Message::DecoderBase { cerr << "ERROR: Non map object in file" << endl << flush; return; } - Atlas::Message::Object::MapType omap = obj.AsMap(); + const Atlas::Message::Object::MapType & omap = obj.AsMap(); if (omap.find("id") == omap.end()) { cerr << "WARNING: Object in file has no id. Not stored." << endl << flush; return; } m_count++; - const string & id = omap["id"].AsString(); + const string & id = omap.find("id")->second.AsString(); m_db->storeInWorld(obj, id.c_str()); } public: diff --git a/tools/cyisoload.cpp b/tools/cyisoload.cpp index ca8c33211..3a3de37b9 100644 --- a/tools/cyisoload.cpp +++ b/tools/cyisoload.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include #include diff --git a/tools/cypasswd.cpp b/tools/cypasswd.cpp index dec824bdc..760c808ae 100644 --- a/tools/cypasswd.cpp +++ b/tools/cypasswd.cpp @@ -1,6 +1,6 @@ // This file may be redistributed and modified only under the terms of // the GNU General Public License (See COPYING for details). -// Copyright (C) 2000 Alistair Riddoch +// Copyright (C) 2001 Alistair Riddoch #include #include