Server is ready to send
This commit is contained in:
@@ -30,12 +30,12 @@ CreatureManager::~CreatureManager() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//arg: a list of creatures to be updated in the clients
|
//arg: a list of creatures to be updated in the clients
|
||||||
int CreatureManager::Update(std::list<CreatureData*>* creatureList) {
|
int CreatureManager::Update(std::list<std::pair<const int, CreatureData*>>* creatureList) {
|
||||||
int ret;
|
int ret;
|
||||||
for (auto& it : elementMap) {
|
for (auto& it : elementMap) {
|
||||||
ret = it.second.Update(lua);
|
ret = it.second.Update(lua);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
creatureList->push_back(&it.second);
|
creatureList->push_back(std::pair<const int, CreatureData*>(it.first, &it.second));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public:
|
|||||||
~CreatureManager();
|
~CreatureManager();
|
||||||
|
|
||||||
//common public methods
|
//common public methods
|
||||||
int Update(std::list<CreatureData*>* creatureList);
|
int Update(std::list<std::pair<const int, CreatureData*>>* creatureList);
|
||||||
|
|
||||||
int Create(std::string avatar, int scriptRef);
|
int Create(std::string avatar, int scriptRef);
|
||||||
void Unload(int uid);
|
void Unload(int uid);
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
#config
|
#config
|
||||||
INCLUDES+=. .. ../characters ../creatures ../entities ../monsters ../triggers ../../common/gameplay ../../common/map ../../common/utilities
|
INCLUDES+=. .. ../characters ../creatures ../entities ../monsters ../triggers ../../common/gameplay ../../common/map ../../common/network ../../common/network/packet_types ../../common/utilities
|
||||||
LIBS+=
|
LIBS+=
|
||||||
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
CXXFLAGS+=-std=c++11 $(addprefix -I,$(INCLUDES))
|
||||||
|
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "room_data.hpp"
|
#include "room_data.hpp"
|
||||||
|
|
||||||
|
#include "serial_packet.hpp"
|
||||||
|
#include "server_utilities.hpp"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <stack>
|
#include <stack>
|
||||||
@@ -99,10 +102,15 @@ void RoomData::RunFrame() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//a list of creatures that need to be updated client-side
|
//a list of creatures that need to be updated client-side
|
||||||
std::list<CreatureData*> creatureList;
|
std::list< std::pair<const int, CreatureData*>> creatureList;
|
||||||
creatureMgr.Update(&creatureList);
|
creatureMgr.Update(&creatureList);
|
||||||
|
|
||||||
//TODO: (0) send the updates
|
//send the updates
|
||||||
|
for (auto& it : creatureList) {
|
||||||
|
CreaturePacket packet;
|
||||||
|
copyCreatureToPacket(&packet, it.second, it.first);
|
||||||
|
//TODO: send
|
||||||
|
}
|
||||||
|
|
||||||
//TODO: creature/character collisions
|
//TODO: creature/character collisions
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -169,6 +169,14 @@ void copyCharacterToPacket(CharacterPacket* const packet, CharacterData* const c
|
|||||||
packet->bounds = characterData->GetBounds();
|
packet->bounds = characterData->GetBounds();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void copyCreatureToPacket(CreaturePacket* const packet, CreatureData* const creatureData, int creatureIndex) {
|
||||||
|
packet->creatureIndex = creatureIndex;
|
||||||
|
strncpy(packet->avatar, creatureData->GetAvatar().c_str(), PACKET_STRING_SIZE);
|
||||||
|
packet->origin = creatureData->GetOrigin();
|
||||||
|
packet->motion = creatureData->GetMotion();
|
||||||
|
packet->bounds = creatureData->GetBounds();
|
||||||
|
}
|
||||||
|
|
||||||
void pumpAndChangeRooms(int characterIndex, int newRoomIndex) {
|
void pumpAndChangeRooms(int characterIndex, int newRoomIndex) {
|
||||||
//get the character object
|
//get the character object
|
||||||
CharacterData* character = CharacterManager::GetSingleton().Get(characterIndex);
|
CharacterData* character = CharacterManager::GetSingleton().Get(characterIndex);
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "character_data.hpp"
|
#include "character_data.hpp"
|
||||||
|
#include "creature_data.hpp"
|
||||||
#include "serial_packet.hpp"
|
#include "serial_packet.hpp"
|
||||||
#include "vector2.hpp"
|
#include "vector2.hpp"
|
||||||
|
|
||||||
@@ -34,5 +35,8 @@ void pumpPacketProximity(SerialPacket* const argPacket, int roomIndex, Vector2 p
|
|||||||
|
|
||||||
void copyCharacterToPacket(CharacterPacket* const packet, int characterIndex);
|
void copyCharacterToPacket(CharacterPacket* const packet, int characterIndex);
|
||||||
void copyCharacterToPacket(CharacterPacket* const packet, CharacterData* const characterData, int characterIndex);
|
void copyCharacterToPacket(CharacterPacket* const packet, CharacterData* const characterData, int characterIndex);
|
||||||
|
|
||||||
|
void copyCreatureToPacket(CreaturePacket* const packet, CreatureData* const creatureData, int creatureIndex);
|
||||||
|
|
||||||
void pumpAndChangeRooms(int characterIndex, int newRoomIndex);
|
void pumpAndChangeRooms(int characterIndex, int newRoomIndex);
|
||||||
void pumpAndChangeRooms(CharacterData* const characterData, int newRoomIndex, int characterIndex);
|
void pumpAndChangeRooms(CharacterData* const characterData, int newRoomIndex, int characterIndex);
|
||||||
|
|||||||
Reference in New Issue
Block a user