Don't send objects or map data before definitions have been sent

This commit is contained in:
Perttu Ahola 2011-12-02 01:18:25 +02:00
parent e4daa4c065
commit 9d67037570
2 changed files with 20 additions and 2 deletions

@ -1448,6 +1448,12 @@ void Server::AsyncRunStep()
i.atEnd() == false; i++) i.atEnd() == false; i++)
{ {
RemoteClient *client = i.getNode()->getValue(); RemoteClient *client = i.getNode()->getValue();
// If definitions and textures have not been sent, don't
// send objects either
if(!client->definitions_sent)
continue;
Player *player = m_env->getPlayer(client->peer_id); Player *player = m_env->getPlayer(client->peer_id);
if(player==NULL) if(player==NULL)
{ {
@ -2173,7 +2179,7 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
// Send inventory to player // Send inventory to player
UpdateCrafting(peer_id); UpdateCrafting(peer_id);
SendInventory(peer_id); SendInventory(peer_id);
// Send player items to all players // Send player items to all players
SendPlayerItems(); SendPlayerItems();
@ -2189,6 +2195,9 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
m_con.Send(peer_id, 0, data, true); m_con.Send(peer_id, 0, data, true);
} }
// Now the client should know about everything
getClient(peer_id)->definitions_sent = true;
// Send information about server to player in chat // Send information about server to player in chat
SendChatMessage(peer_id, getStatusString()); SendChatMessage(peer_id, getStatusString());
@ -2866,6 +2875,8 @@ void Server::ProcessData(u8 *data, u32 datasize, u16 peer_id)
if(player->hp != 0) if(player->hp != 0)
return; return;
srp->m_respawn_active = false;
RespawnPlayer(player); RespawnPlayer(player);
actionstream<<player->getName()<<" respawns at " actionstream<<player->getName()<<" respawns at "
@ -4183,6 +4194,11 @@ void Server::SendBlocks(float dtime)
RemoteClient *client = i.getNode()->getValue(); RemoteClient *client = i.getNode()->getValue();
assert(client->peer_id == i.getNode()->getKey()); assert(client->peer_id == i.getNode()->getKey());
// If definitions and textures have not been sent, don't
// send MapBlocks either
if(!client->definitions_sent)
continue;
total_sending += client->SendingCount(); total_sending += client->SendingCount();
if(client->serialization_version == SER_FMT_VER_INVALID) if(client->serialization_version == SER_FMT_VER_INVALID)
@ -4400,7 +4416,6 @@ void Server::RespawnPlayer(Player *player)
{ {
player->hp = 20; player->hp = 20;
ServerRemotePlayer *srp = static_cast<ServerRemotePlayer*>(player); ServerRemotePlayer *srp = static_cast<ServerRemotePlayer*>(player);
srp->m_respawn_active = false;
bool repositioned = scriptapi_on_respawnplayer(m_lua, srp); bool repositioned = scriptapi_on_respawnplayer(m_lua, srp);
if(!repositioned){ if(!repositioned){
v3f pos = findSpawnPos(m_env->getServerMap()); v3f pos = findSpawnPos(m_env->getServerMap());

@ -248,6 +248,8 @@ public:
// Version is stored in here after INIT before INIT2 // Version is stored in here after INIT before INIT2
u8 pending_serialization_version; u8 pending_serialization_version;
bool definitions_sent;
RemoteClient(): RemoteClient():
m_time_from_building(9999), m_time_from_building(9999),
m_excess_gotblocks(0) m_excess_gotblocks(0)
@ -256,6 +258,7 @@ public:
serialization_version = SER_FMT_VER_INVALID; serialization_version = SER_FMT_VER_INVALID;
net_proto_version = 0; net_proto_version = 0;
pending_serialization_version = SER_FMT_VER_INVALID; pending_serialization_version = SER_FMT_VER_INVALID;
definitions_sent = false;
m_nearest_unsent_d = 0; m_nearest_unsent_d = 0;
m_nearest_unsent_reset_timer = 0.0; m_nearest_unsent_reset_timer = 0.0;
m_nothing_to_send_counter = 0; m_nothing_to_send_counter = 0;