Server responds to barrier queries
This commit is contained in:
@@ -21,7 +21,6 @@
|
|||||||
*/
|
*/
|
||||||
#include "barrier_manager.hpp"
|
#include "barrier_manager.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
|
||||||
void BarrierManager::DrawTo(SDL_Renderer* const dest, Sint16 x, Sint16 y, double scaleX, double scaleY) {
|
void BarrierManager::DrawTo(SDL_Renderer* const dest, Sint16 x, Sint16 y, double scaleX, double scaleY) {
|
||||||
for (auto& it : barrierMap) {
|
for (auto& it : barrierMap) {
|
||||||
it.second.DrawTo(dest, x, y);
|
it.second.DrawTo(dest, x, y);
|
||||||
@@ -38,7 +37,6 @@ void BarrierManager::UnloadBaseImage() {
|
|||||||
|
|
||||||
void BarrierManager::LoadTemplateImages(SDL_Renderer* renderer, std::list<std::string> names) {
|
void BarrierManager::LoadTemplateImages(SDL_Renderer* renderer, std::list<std::string> names) {
|
||||||
for (auto& it : names) {
|
for (auto& it : names) {
|
||||||
//TODO: check the state of the local flag
|
|
||||||
templateImages.emplace(it, Image(renderer, it));
|
templateImages.emplace(it, Image(renderer, it));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -49,8 +47,6 @@ void BarrierManager::UnloadTemplateImages() {
|
|||||||
|
|
||||||
BaseBarrier* BarrierManager::Create(int index) {
|
BaseBarrier* BarrierManager::Create(int index) {
|
||||||
barrierMap.emplace( index, BaseBarrier(baseImage, templateImages) );
|
barrierMap.emplace( index, BaseBarrier(baseImage, templateImages) );
|
||||||
|
|
||||||
//DEBUG: debugging
|
|
||||||
return &barrierMap[index];
|
return &barrierMap[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -130,6 +130,10 @@ int RoomData::GetRoomIndex() {
|
|||||||
return roomIndex;
|
return roomIndex;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BarrierManager* RoomData::GetBarrierMgr() {
|
||||||
|
return &barrierMgr;
|
||||||
|
}
|
||||||
|
|
||||||
std::list<CharacterData*>* RoomData::GetCharacterList() {
|
std::list<CharacterData*>* RoomData::GetCharacterList() {
|
||||||
return &characterList;
|
return &characterList;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ public:
|
|||||||
int SetRoomIndex(int i);
|
int SetRoomIndex(int i);
|
||||||
int GetRoomIndex();
|
int GetRoomIndex();
|
||||||
|
|
||||||
|
BarrierManager* GetBarrierMgr();
|
||||||
std::list<CharacterData*>* GetCharacterList();
|
std::list<CharacterData*>* GetCharacterList();
|
||||||
CreatureManager* GetCreatureMgr();
|
CreatureManager* GetCreatureMgr();
|
||||||
RegionPagerLua* GetPager();
|
RegionPagerLua* GetPager();
|
||||||
|
|||||||
@@ -302,11 +302,17 @@ void ServerApplication::HandlePacket(SerialPacket* const argPacket) {
|
|||||||
hCharacterMovement(static_cast<CharacterPacket*>(argPacket));
|
hCharacterMovement(static_cast<CharacterPacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//TODO: (1) merge character, creature & barrier queries & updates together?
|
||||||
//creature management
|
//creature management
|
||||||
case SerialPacketType::QUERY_CREATURE_EXISTS:
|
case SerialPacketType::QUERY_CREATURE_EXISTS:
|
||||||
hQueryCreatureExists(static_cast<CreaturePacket*>(argPacket));
|
hQueryCreatureExists(static_cast<CreaturePacket*>(argPacket));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
//barrier management
|
||||||
|
case SerialPacketType::QUERY_BARRIER_EXISTS:
|
||||||
|
hQueryBarrierExists(static_cast<BarrierPacket*>(argPacket));
|
||||||
|
break;
|
||||||
|
|
||||||
//chat
|
//chat
|
||||||
case SerialPacketType::TEXT_BROADCAST:
|
case SerialPacketType::TEXT_BROADCAST:
|
||||||
hTextBroadcast(static_cast<TextPacket*>(argPacket));
|
hTextBroadcast(static_cast<TextPacket*>(argPacket));
|
||||||
@@ -820,6 +826,27 @@ void ServerApplication::hQueryCreatureExists(CreaturePacket* const argPacket) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-------------------------
|
||||||
|
//barrier management
|
||||||
|
//-------------------------
|
||||||
|
|
||||||
|
//TODO: On barrier create, etc.
|
||||||
|
|
||||||
|
void ServerApplication::hQueryBarrierExists(BarrierPacket* const argPacket) {
|
||||||
|
//respond with all barrier data
|
||||||
|
BarrierPacket newPacket;
|
||||||
|
|
||||||
|
BarrierManager* barrierMgr = roomMgr.Find(argPacket->roomIndex)->GetBarrierMgr();
|
||||||
|
|
||||||
|
//TODO: (0) move this into the room class
|
||||||
|
for (auto& it : *(barrierMgr->GetContainer()) ) {
|
||||||
|
copyBarrierToPacket(&newPacket, &(it.second), it.first);
|
||||||
|
newPacket.type = SerialPacketType::QUERY_BARRIER_EXISTS;
|
||||||
|
newPacket.roomIndex = argPacket->roomIndex;
|
||||||
|
network.SendTo(argPacket->srcAddress, static_cast<SerialPacket*>(&newPacket));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//-------------------------
|
//-------------------------
|
||||||
//chat
|
//chat
|
||||||
//-------------------------
|
//-------------------------
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ private:
|
|||||||
//creature management
|
//creature management
|
||||||
void hQueryCreatureExists(CreaturePacket* const);
|
void hQueryCreatureExists(CreaturePacket* const);
|
||||||
|
|
||||||
|
//barrier management
|
||||||
|
void hQueryBarrierExists(BarrierPacket* const);
|
||||||
|
|
||||||
//chat
|
//chat
|
||||||
void hTextBroadcast(TextPacket* const);
|
void hTextBroadcast(TextPacket* const);
|
||||||
void hTextSpeech(TextPacket* const);
|
void hTextSpeech(TextPacket* const);
|
||||||
|
|||||||
Reference in New Issue
Block a user