mirror of
https://github.com/worldforge/cyphesis
synced 2026-08-13 12:26:04 -04:00
* client/Py_CreatorClient.cpp, common/BaseEntity.cpp, common/BaseEntity.h, modules/Location.cpp, modules/Location.h, rulesets/Area.cpp, rulesets/Area.h, rulesets/Character.cpp, rulesets/Character.h, rulesets/Entity.cpp, rulesets/Entity.h, rulesets/Line.cpp, rulesets/Line.h, rulesets/MemMap.cpp, rulesets/Pedestrian.cpp, rulesets/Plant.cpp, rulesets/Plant.h, rulesets/Py_Mind.cpp, rulesets/Py_Object.cpp, rulesets/Py_Thing.cpp, rulesets/Python_API.cpp, rulesets/Stackable.cpp, rulesets/Stackable.h, rulesets/Thing.cpp, rulesets/World.cpp, rulesets/World.h, server/Account.cpp, server/Account.h, server/Admin.cpp, server/Connection.cpp, server/Lobby.cpp, server/Lobby.h, server/Player.cpp, server/Player.h, server/ServerRouting.cpp, server/ServerRouting.h, tests/Areatest.cpp, tests/Entitytest.cpp, tests/Foodtest.cpp, tests/Linetest.cpp, tests/Planttest.cpp, tests/Stackabletest.cpp, tests/Structuretest.cpp, tests/Thingtest.cpp, tests/Worldtest.cpp: Replace addToObject() with addToMessage() throughout. * server/Account.cpp, server/Lobby.cpp: Use BaseEntity::addToMessage(). * server/Player.cpp: Make adding character types attribute to Message more efficient.
83 lines
2.3 KiB
C++
83 lines
2.3 KiB
C++
// This file may be redistributed and modified only under the terms of
|
|
// the GNU General Public License (See COPYING for details).
|
|
// Copyright (C) 2003 Alistair Riddoch
|
|
|
|
#include "IGEntityExerciser.h"
|
|
#include "allOperations.h"
|
|
|
|
#include "rulesets/Stackable.h"
|
|
|
|
#include <cassert>
|
|
|
|
int main()
|
|
{
|
|
Stackable e("testId");
|
|
|
|
IGEntityExerciser<Stackable> ee(e);
|
|
|
|
// Throw an op of every type at the entity
|
|
ee.runOperations();
|
|
|
|
// Subscribe the entity to every class of op
|
|
std::set<std::string> opNames;
|
|
ee.addAllOperations(opNames);
|
|
ee.subscribeOperations(opNames);
|
|
|
|
// Throw an op of every type at the entity again now it is subscribed
|
|
ee.runOperations();
|
|
|
|
std::set<std::string> attrNames;
|
|
attrNames.insert("status");
|
|
attrNames.insert("id");
|
|
attrNames.insert("name");
|
|
attrNames.insert("mass");
|
|
attrNames.insert("bbox");
|
|
attrNames.insert("contains");
|
|
attrNames.insert("num");
|
|
|
|
// Make sure we have all the default attributes
|
|
assert(ee.checkAttributes(attrNames));
|
|
|
|
attrNames.insert("test_int");
|
|
attrNames.insert("test_float");
|
|
attrNames.insert("test_list_string");
|
|
attrNames.insert("test_list_int");
|
|
attrNames.insert("test_list_float");
|
|
attrNames.insert("test_map_string");
|
|
attrNames.insert("test_map_int");
|
|
attrNames.insert("test_map_float");
|
|
|
|
// Make sure we don't have the test attributes yet
|
|
assert(!ee.checkAttributes(attrNames));
|
|
|
|
// Add the test attributes
|
|
e.set("test_int", 1);
|
|
e.set("test_float", 1.f);
|
|
e.set("test_list_string", "test_value");
|
|
e.set("test_list_int", ListType(1, 1));
|
|
e.set("test_list_float", ListType(1, 1.f));
|
|
e.set("test_map_string", ListType(1, "test_value"));
|
|
MapType test_map;
|
|
test_map["test_key"] = 1;
|
|
e.set("test_map_int", test_map);
|
|
test_map["test_key"] = 1.f;
|
|
e.set("test_map_float", test_map);
|
|
test_map["test_key"] = "test_value";
|
|
e.set("test_map_string", test_map);
|
|
|
|
// Make sure we have the test attributes now
|
|
assert(ee.checkAttributes(attrNames));
|
|
|
|
MapType entityAsAtlas;
|
|
|
|
// Dump a representation of the entity into an Atlas Message
|
|
e.addToMessage(entityAsAtlas);
|
|
|
|
// Make sure we got at least some of it
|
|
assert(entityAsAtlas.size() > 14);
|
|
|
|
// Read the contents of the Atlas Message back in
|
|
e.merge(entityAsAtlas);
|
|
|
|
return 0;
|
|
}
|