The client->server->client region protocol is working
This commit is contained in:
@@ -114,7 +114,7 @@ void ServerApplication::Init(int argc, char** argv) {
|
||||
cout << "Startup completed successfully" << endl;
|
||||
|
||||
//debugging
|
||||
mapPager.GetRegion(0, 0);
|
||||
//
|
||||
}
|
||||
|
||||
void ServerApplication::Loop() {
|
||||
@@ -180,6 +180,9 @@ void ServerApplication::HandlePacket(NetworkPacket packet) {
|
||||
case NetworkPacket::Type::PLAYER_UPDATE:
|
||||
HandlePlayerUpdate(packet);
|
||||
break;
|
||||
case NetworkPacket::Type::REGION_REQUEST:
|
||||
HandleRegionRequest(packet);
|
||||
break;
|
||||
//handle errors
|
||||
default:
|
||||
throw(runtime_error("Unknown NetworkPacket::Type encountered"));
|
||||
@@ -340,6 +343,14 @@ void ServerApplication::HandlePlayerUpdate(NetworkPacket packet) {
|
||||
PumpPacket(packet);
|
||||
}
|
||||
|
||||
void ServerApplication::HandleRegionRequest(NetworkPacket packet) {
|
||||
char buffer[PACKET_BUFFER_SIZE];
|
||||
packet.meta.type = NetworkPacket::Type::REGION_CONTENT;
|
||||
packet.regionInfo.region = mapPager.GetRegion(packet.regionInfo.x, packet.regionInfo.y);
|
||||
serialize(&packet, buffer);
|
||||
network.Send(&packet.meta.srcAddress, buffer, PACKET_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
void ServerApplication::PumpPacket(NetworkPacket packet) {
|
||||
//I don't really like this, but it'll do for now
|
||||
char buffer[PACKET_BUFFER_SIZE];
|
||||
|
||||
Reference in New Issue
Block a user