Committing incomplete work; need to fix an urgent bug
This commit is contained in:
@@ -30,9 +30,33 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
class CharacterData: public Entity {
|
class CharacterData: public Entity {
|
||||||
public:
|
public:
|
||||||
CharacterData() = default;
|
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;
|
~CharacterData() = default;
|
||||||
|
|
||||||
//accessors and mutators
|
//accessors and mutators
|
||||||
|
|||||||
@@ -58,9 +58,10 @@ void RoomManager::PushEntity(Entity* entity) {
|
|||||||
throw(std::runtime_error(msg.str()));
|
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 << "\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) {
|
void RoomManager::PopEntity(Entity* entity) {
|
||||||
@@ -76,9 +77,9 @@ void RoomManager::PopEntity(Entity* entity) {
|
|||||||
throw(std::runtime_error(msg.str()));
|
throw(std::runtime_error(msg.str()));
|
||||||
}
|
}
|
||||||
|
|
||||||
it->second.entityList.remove_if([&](Entity* ptr) -> bool {
|
it->second.entityList.remove_if([entity](Entity* ptr) -> bool {
|
||||||
bool b = &(*ptr) == &(*entity);
|
bool b = (entity == ptr);
|
||||||
std::cout << "\tmatch(" << int(&(*ptr)) << "," << int(&(*entity)) << "): " << b << std::endl;
|
std::cout << "\tmatch(" << int(ptr) << "," << int(entity) << "): " << b << std::endl;
|
||||||
return b;
|
return b;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ void ServerApplication::HandleCharacterCreate(CharacterPacket* const argPacket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//push this character to the rooms
|
//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
|
//pump this character to all clients
|
||||||
CharacterPacket newPacket;
|
CharacterPacket newPacket;
|
||||||
@@ -90,7 +90,7 @@ void ServerApplication::HandleCharacterDelete(CharacterPacket* const argPacket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//delete the character
|
//delete the character
|
||||||
roomMgr.PopEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
|
// roomMgr.PopEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
|
||||||
characterMgr.Delete(characterIndex);
|
characterMgr.Delete(characterIndex);
|
||||||
|
|
||||||
//pump character delete
|
//pump character delete
|
||||||
@@ -124,6 +124,7 @@ void ServerApplication::HandleCharacterLoad(CharacterPacket* const argPacket) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//push this character to the rooms
|
//push this character to the rooms
|
||||||
|
std::cout << "pushing index " << characterIndex << std::endl;
|
||||||
roomMgr.PushEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
|
roomMgr.PushEntity(static_cast<Entity*>(characterMgr.Get(characterIndex)));
|
||||||
|
|
||||||
//pump this character to all clients
|
//pump this character to all clients
|
||||||
@@ -157,6 +158,7 @@ void ServerApplication::HandleCharacterUnload(CharacterPacket* const argPacket)
|
|||||||
}
|
}
|
||||||
|
|
||||||
//unload the character
|
//unload the character
|
||||||
|
std::cout << "poping index " << argPacket->characterIndex << std::endl;
|
||||||
roomMgr.PopEntity(static_cast<Entity*>(characterData));
|
roomMgr.PopEntity(static_cast<Entity*>(characterData));
|
||||||
characterMgr.Unload(argPacket->characterIndex);
|
characterMgr.Unload(argPacket->characterIndex);
|
||||||
|
|
||||||
|
|||||||
@@ -143,6 +143,7 @@ void ServerApplication::FullAccountUnload(int index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void ServerApplication::FullCharacterUnload(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 {
|
characterMgr.UnloadIf([&](std::pair<const int, CharacterData> character) -> bool {
|
||||||
//skip the wrong characters
|
//skip the wrong characters
|
||||||
if (character.first != index) {
|
if (character.first != index) {
|
||||||
@@ -150,7 +151,8 @@ void ServerApplication::FullCharacterUnload(int index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//pop from the rooms
|
//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
|
//pump character unload
|
||||||
CharacterPacket newPacket;
|
CharacterPacket newPacket;
|
||||||
|
|||||||
Reference in New Issue
Block a user