mirror of
https://git.huckle.dev/Huckles-Minecraft-Archive/4jcraft.git
synced 2026-05-25 06:55:09 +00:00
refactor: unglob std::shared_ptr
This commit is contained in:
@@ -62,7 +62,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
||||
// logger.info("Disconnecting " + getName() + ": " + reason);
|
||||
fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick);
|
||||
app.DebugPrintf("Pending connection disconnect: %d\n", reason );
|
||||
connection->send( shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) );
|
||||
connection->send( std::shared_ptr<DisconnectPacket>( new DisconnectPacket(reason) ) );
|
||||
connection->sendAndQuit();
|
||||
done = true;
|
||||
// } catch (Exception e) {
|
||||
@@ -70,7 +70,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason)
|
||||
// }
|
||||
}
|
||||
|
||||
void PendingConnection::handlePreLogin(shared_ptr<PreLoginPacket> packet)
|
||||
void PendingConnection::handlePreLogin(std::shared_ptr<PreLoginPacket> packet)
|
||||
{
|
||||
if (packet->m_netcodeVersion != MINECRAFT_NET_VERSION)
|
||||
{
|
||||
@@ -104,7 +104,7 @@ void PendingConnection::sendPreLoginResponse()
|
||||
PlayerList *playerList = MinecraftServer::getInstance()->getPlayers();
|
||||
for(AUTO_VAR(it, playerList->players.begin()); it != playerList->players.end(); ++it)
|
||||
{
|
||||
shared_ptr<ServerPlayer> player = *it;
|
||||
std::shared_ptr<ServerPlayer> player = *it;
|
||||
// If the offline Xuid is invalid but the online one is not then that's guest which we should ignore
|
||||
// If the online Xuid is invalid but the offline one is not then we are definitely an offline game so dont care about UGC
|
||||
|
||||
@@ -129,16 +129,16 @@ void PendingConnection::sendPreLoginResponse()
|
||||
if (false)// server->onlineMode) // 4J - removed
|
||||
{
|
||||
loginKey = L"TOIMPLEMENT"; // 4J - todo Long.toHexString(random.nextLong());
|
||||
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) );
|
||||
connection->send( std::shared_ptr<PreLoginPacket>( new PreLoginPacket(loginKey, ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion, szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex) ) );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
connection->send( shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) );
|
||||
connection->send( std::shared_ptr<PreLoginPacket>( new PreLoginPacket(L"-", ugcXuids, ugcXuidCount, ugcFriendsOnlyBits, server->m_ugcPlayersVersion,szUniqueMapName,app.GetGameHostOption(eGameHostOption_All),hostIndex, server->m_texturePackId) ) );
|
||||
}
|
||||
}
|
||||
|
||||
void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
void PendingConnection::handleLogin(std::shared_ptr<LoginPacket> packet)
|
||||
{
|
||||
fprintf(stderr, "[LOGIN-SRV] handleLogin called! clientVersion=%d\n", packet->clientVersion);
|
||||
//name = packet->userName;
|
||||
@@ -199,7 +199,7 @@ void PendingConnection::handleLogin(shared_ptr<LoginPacket> packet)
|
||||
|
||||
}
|
||||
|
||||
void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
|
||||
void PendingConnection::handleAcceptedLogin(std::shared_ptr<LoginPacket> packet)
|
||||
{
|
||||
if(packet->m_ugcPlayersVersion != server->m_ugcPlayersVersion)
|
||||
{
|
||||
@@ -212,7 +212,7 @@ void PendingConnection::handleAcceptedLogin(shared_ptr<LoginPacket> packet)
|
||||
PlayerUID playerXuid = packet->m_offlineXuid;
|
||||
if(playerXuid == INVALID_XUID) playerXuid = packet->m_onlineXuid;
|
||||
|
||||
shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
|
||||
std::shared_ptr<ServerPlayer> playerEntity = server->getPlayers()->getPlayerForLogin(this, name, playerXuid,packet->m_onlineXuid);
|
||||
if (playerEntity != NULL)
|
||||
{
|
||||
server->getPlayers()->placeNewPlayer(connection, playerEntity, packet);
|
||||
@@ -228,12 +228,12 @@ void PendingConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason,
|
||||
done = true;
|
||||
}
|
||||
|
||||
void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet)
|
||||
void PendingConnection::handleGetInfo(std::shared_ptr<GetInfoPacket> packet)
|
||||
{
|
||||
//try {
|
||||
//String message = server->motd + "§" + server->players->getPlayerCount() + "§" + server->players->getMaxPlayers();
|
||||
//connection->send(new DisconnectPacket(message));
|
||||
connection->send(shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) );
|
||||
connection->send(std::shared_ptr<DisconnectPacket>(new DisconnectPacket(DisconnectPacket::eDisconnect_ServerFull) ) );
|
||||
connection->sendAndQuit();
|
||||
server->connection->removeSpamProtection(connection->getSocket());
|
||||
done = true;
|
||||
@@ -242,17 +242,17 @@ void PendingConnection::handleGetInfo(shared_ptr<GetInfoPacket> packet)
|
||||
//}
|
||||
}
|
||||
|
||||
void PendingConnection::handleKeepAlive(shared_ptr<KeepAlivePacket> packet)
|
||||
void PendingConnection::handleKeepAlive(std::shared_ptr<KeepAlivePacket> packet)
|
||||
{
|
||||
// Ignore
|
||||
}
|
||||
|
||||
void PendingConnection::onUnhandledPacket(shared_ptr<Packet> packet)
|
||||
void PendingConnection::onUnhandledPacket(std::shared_ptr<Packet> packet)
|
||||
{
|
||||
disconnect(DisconnectPacket::eDisconnect_UnexpectedPacket);
|
||||
}
|
||||
|
||||
void PendingConnection::send(shared_ptr<Packet> packet)
|
||||
void PendingConnection::send(std::shared_ptr<Packet> packet)
|
||||
{
|
||||
connection->send(packet);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user