Merge pull request #4789 from janisozaur/server-load-new-map

Fix #4755: Crash loading new map while running a server
This commit is contained in:
Ted John 2016-11-11 19:08:34 +00:00 committed by GitHub
commit 7a4ef4073f
1 changed files with 13 additions and 3 deletions

View File

@ -927,11 +927,21 @@ void Network::Server_Send_MAP(NetworkConnection* connection)
SDL_RWops* rw = SDL_RWFromFP(temp, SDL_TRUE);
size_t out_size;
unsigned char *header;
header = save_for_network(rw, out_size, connection->RequestedObjects);
std::vector<const ObjectRepositoryItem *> objects;
if (connection) {
objects = connection->RequestedObjects;
} else {
// This will send all custom objects to connected clients
// TODO: fix it so custom objects negotiation is performed even in this case.
objects = scenario_get_packable_objects();
}
header = save_for_network(rw, out_size, objects);
SDL_RWclose(rw);
if (header == nullptr) {
connection->SetLastDisconnectReason(STR_MULTIPLAYER_CONNECTION_CLOSED);
connection->Socket->Disconnect();
if (connection) {
connection->SetLastDisconnectReason(STR_MULTIPLAYER_CONNECTION_CLOSED);
connection->Socket->Disconnect();
}
return;
}
size_t chunksize = 65000;