Room transitions are working smoothly, read more

Although the room transitions are working fairly well, it is still heavy
handed, and a number of optimizations can be done. On the whole, this
needs a review.
This commit is contained in:
Kayne Ruse
2015-03-09 23:26:37 +11:00
parent 81b3769188
commit 4d71d4cc40
7 changed files with 109 additions and 19 deletions
+19 -6
View File
@@ -87,6 +87,15 @@ void World::hCharacterCreate(CharacterPacket* const argPacket) {
//focus on this character's info
characterIndex = argPacket->characterIndex;
roomIndex = argPacket->roomIndex;
//query the world state
CharacterPacket newPacket;
memset(&newPacket, 0, MAX_PACKET_SIZE);
newPacket.type = SerialPacketType::QUERY_CHARACTER_EXISTS; //TODO: (2) the EXISTS and LOCATION queries are backwards?
newPacket.roomIndex = roomIndex;
network.SendTo(Channels::SERVER, &newPacket);
newPacket.type = SerialPacketType::QUERY_MONSTER_EXISTS;
network.SendTo(Channels::SERVER, &newPacket);
}
//debug
@@ -110,10 +119,14 @@ void World::hCharacterDelete(CharacterPacket* const argPacket) {
//clear the room
roomIndex = -1;
regionPager.UnloadAll();
characterMap.clear();
monsterMap.clear();
}
else {
//remove this character
characterMap.erase(characterIt);
}
//remove this character
characterMap.erase(characterIt);
//debug
std::cout << "Character Delete, total: " << characterMap.size() << std::endl;
@@ -121,9 +134,9 @@ void World::hCharacterDelete(CharacterPacket* const argPacket) {
void World::hQueryCharacterExists(CharacterPacket* const argPacket) {
//prevent a double message about this player's character
if (argPacket->accountIndex == accountIndex) {
return;
}
// if (argPacket->accountIndex == accountIndex) {
// return;
// }
//ignore characters in a different room (sub-optimal)
if (argPacket->roomIndex != roomIndex) {
+1
View File
@@ -71,6 +71,7 @@ World::World(int* const argClientIndex, int* const argAccountIndex):
newPacket.accountIndex = accountIndex;
network.SendTo(Channels::SERVER, &newPacket);
//TODO: (2) replace this duplication with a request for just this player's character
//query the world state
memset(&newPacket, 0, MAX_PACKET_SIZE);
newPacket.type = SerialPacketType::QUERY_CHARACTER_EXISTS;