Fix locking bugs and make inventory deserialization errors more specific

This commit is contained in:
ShadowNinja 2014-09-11 20:12:52 -04:00
parent 6bc4cad0ed
commit c061bdd37f
2 changed files with 11 additions and 6 deletions

@ -938,7 +938,7 @@ void Inventory::deSerialize(std::istream &is)
} }
else else
{ {
throw SerializationError("invalid inventory specifier"); throw SerializationError("invalid inventory specifier: " + name);
} }
} }
} }

@ -1169,11 +1169,16 @@ PlayerSAO* Server::StageTwoClientInit(u16 peer_id)
std::string playername = ""; std::string playername = "";
PlayerSAO *playersao = NULL; PlayerSAO *playersao = NULL;
m_clients.Lock(); m_clients.Lock();
try {
RemoteClient* client = m_clients.lockedGetClientNoEx(peer_id, CS_InitDone); RemoteClient* client = m_clients.lockedGetClientNoEx(peer_id, CS_InitDone);
if (client != NULL) { if (client != NULL) {
playername = client->getName(); playername = client->getName();
playersao = emergePlayer(playername.c_str(), peer_id); playersao = emergePlayer(playername.c_str(), peer_id);
} }
} catch (std::exception &e) {
m_clients.Unlock();
throw;
}
m_clients.Unlock(); m_clients.Unlock();
RemotePlayer *player = RemotePlayer *player =
@ -3869,7 +3874,7 @@ void Server::SendBlocks(float dtime)
RemoteClient *client = m_clients.lockedGetClientNoEx(*i, CS_Active); RemoteClient *client = m_clients.lockedGetClientNoEx(*i, CS_Active);
if (client == NULL) if (client == NULL)
return; continue;
total_sending += client->SendingCount(); total_sending += client->SendingCount();
client->GetNextBlocks(m_env,m_emerge, dtime, queue); client->GetNextBlocks(m_env,m_emerge, dtime, queue);