Committing incomplete work; need to fix an urgent bug

This commit is contained in:
Kayne Ruse
2015-01-02 06:57:20 +11:00
parent 4579f9f388
commit b2452fb6fe
4 changed files with 36 additions and 7 deletions
+24
View File
@@ -30,9 +30,33 @@
#include <string>
#include <cmath>
#include <iostream>
class CharacterData: public Entity {
public:
CharacterData() = default;
CharacterData(CharacterData const& rhs) {
std::cerr << "Character copy detected" << std::endl;
owner = rhs.owner;
handle = rhs.handle;
avatar = rhs.avatar;
//entity stuff
roomIndex = rhs.roomIndex;
origin = rhs.origin;
motion = rhs.motion;
}
CharacterData(CharacterData&& rhs) {
std::cerr << "Character move detected" << std::endl;
owner = rhs.owner;
handle = rhs.handle;
avatar = rhs.avatar;
//entity stuff
roomIndex = rhs.roomIndex;
origin = rhs.origin;
motion = rhs.motion;
}
~CharacterData() = default;
//accessors and mutators
+5 -4
View File
@@ -58,9 +58,10 @@ void RoomManager::PushEntity(Entity* entity) {
throw(std::runtime_error(msg.str()));
}
it->second.entityList.push_back(&(*entity));
it->second.entityList.push_back(entity);
std::cout << "\troom[" << it->first << "].entityList.size(): " << it->second.entityList.size() << std::endl;
std::cout << "\tEntity: " << int(entity) << "," << int(it->second.entityList.front()) << std::endl;
}
void RoomManager::PopEntity(Entity* entity) {
@@ -76,9 +77,9 @@ void RoomManager::PopEntity(Entity* entity) {
throw(std::runtime_error(msg.str()));
}
it->second.entityList.remove_if([&](Entity* ptr) -> bool {
bool b = &(*ptr) == &(*entity);
std::cout << "\tmatch(" << int(&(*ptr)) << "," << int(&(*entity)) << "): " << b << std::endl;
it->second.entityList.remove_if([entity](Entity* ptr) -> bool {
bool b = (entity == ptr);
std::cout << "\tmatch(" << int(ptr) << "," << int(entity) << "): " << b << std::endl;
return b;
});
+4 -2
View File
@@ -46,7 +46,7 @@ void ServerApplication::HandleCharacterCreate(CharacterPacket* const argPacket)
}
//push this character to the rooms
roomMgr.PushEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
// roomMgr.PushEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
//pump this character to all clients
CharacterPacket newPacket;
@@ -90,7 +90,7 @@ void ServerApplication::HandleCharacterDelete(CharacterPacket* const argPacket)
}
//delete the character
roomMgr.PopEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
// roomMgr.PopEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
characterMgr.Delete(characterIndex);
//pump character delete
@@ -124,6 +124,7 @@ void ServerApplication::HandleCharacterLoad(CharacterPacket* const argPacket) {
}
//push this character to the rooms
std::cout << "pushing index " << characterIndex << std::endl;
roomMgr.PushEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
//pump this character to all clients
@@ -157,6 +158,7 @@ void ServerApplication::HandleCharacterUnload(CharacterPacket* const argPacket)
}
//unload the character
std::cout << "poping index " << argPacket->characterIndex << std::endl;
roomMgr.PopEntity(static_cast<Entity*>(characterData));
characterMgr.Unload(argPacket->characterIndex);
+3 -1
View File
@@ -143,6 +143,7 @@ void ServerApplication::FullAccountUnload(int index) {
}
void ServerApplication::FullCharacterUnload(int index) {
//BUG: #38 UnloadIf() lambas are taking COPIES of data structures, rather than the structures themselves
characterMgr.UnloadIf([&](std::pair<const int, CharacterData> character) -> bool {
//skip the wrong characters
if (character.first != index) {
@@ -150,7 +151,8 @@ void ServerApplication::FullCharacterUnload(int index) {
}
//pop from the rooms
roomMgr.PopEntity(static_cast<Entity*>(&character.second));
std::cout << "popping index " << index << std::endl;
roomMgr.PopEntity(static_cast<Entity*>(&(character.second)));
//pump character unload
CharacterPacket newPacket;