mirror of
https://github.com/worldforge/cyphesis
synced 2026-08-13 12:26:04 -04:00
2001-04-14 Al Riddoch <alriddoch@zepler.org>
* Substantial re-work of object model. Moved many attributes out of BaseEntity class. Changed WoldRouter so it now handles objects in terms of Entity, rather than BaseEntity. * Code cleanups, including removing reduntant includes, and getting rid of C style comments. * Fixed the way attributes are handled in Set operations and when merging from an Atlas::Message::Object. This fixed problem with setting gender of characters. * rulesets/Pedestrian.*, rulesets/Movement.*: Re-named Movement variables to make them clearer. Added in separate handling for collisions from moving to target position. Modified collision handling so objects can slide next to each other. * rulesets/Thing.cpp, rulesets/Character.cpp: Cleaned up and rationalised movement code. Much shorter, faster and more compact than before. * Made better use of iterators throughout, eliminating unnecessary lookups, and copying of data. * Moved all virtual functions out of header files, making less work for the linker. * Made more use of const references to avoid the need to copy data before being able to inspect it. Al Riddoch <alriddoch@zepler.org>
This commit is contained in:
parent
77a6d063dd
commit
2ccfaadef3
143 changed files with 945 additions and 1024 deletions
|
|
@ -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 <Atlas/Message/Object.h>
|
||||
#include <Atlas/Objects/Root.h>
|
||||
|
|
@ -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; }
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue