aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/ServerConnection.cpp
diff options
context:
space:
mode:
authorvoid_17 <61356189+void2012@users.noreply.github.com>2026-03-06 02:11:18 +0700
committerGitHub <noreply@github.com>2026-03-06 02:11:18 +0700
commit55231bb8d3e1a4e2752ac3d444c4287eb0ca4e8b (patch)
tree953c537a5c66e328e9f4ab29626cf738112d53c0 /Minecraft.Client/ServerConnection.cpp
parent7d6658fe5b3095f35093701b5ab669ffc291e875 (diff)
Remove AUTO_VAR macro and _toString function (#592)
Diffstat (limited to 'Minecraft.Client/ServerConnection.cpp')
-rw-r--r--Minecraft.Client/ServerConnection.cpp30
1 files changed, 15 insertions, 15 deletions
diff --git a/Minecraft.Client/ServerConnection.cpp b/Minecraft.Client/ServerConnection.cpp
index 21d77f22..07616aa4 100644
--- a/Minecraft.Client/ServerConnection.cpp
+++ b/Minecraft.Client/ServerConnection.cpp
@@ -1,6 +1,8 @@
#include "stdafx.h"
#include "Options.h"
#include "ServerConnection.h"
+
+#include <memory>
#include "PendingConnection.h"
#include "PlayerConnection.h"
#include "ServerPlayer.h"
@@ -26,8 +28,8 @@ ServerConnection::~ServerConnection()
// 4J - added to handle incoming connections, to replace thread that original used to have
void ServerConnection::NewIncomingSocket(Socket *socket)
{
- shared_ptr<PendingConnection> unconnectedClient = shared_ptr<PendingConnection>(new PendingConnection(server, socket, L"Connection #" + _toString<int>(connectionCounter++)));
- handleConnection(unconnectedClient);
+ shared_ptr<PendingConnection> unconnectedClient = std::make_shared<PendingConnection>(server, socket, L"Connection #" + std::to_wstring(connectionCounter++));
+ handleConnection(unconnectedClient);
}
void ServerConnection::addPlayerConnection(shared_ptr<PlayerConnection> uc)
@@ -112,8 +114,8 @@ void ServerConnection::tick()
bool ServerConnection::addPendingTextureRequest(const wstring &textureName)
{
- AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
- if( it == m_pendingTextureRequests.end() )
+ auto it = find(m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName);
+ if( it == m_pendingTextureRequests.end() )
{
m_pendingTextureRequests.push_back(textureName);
return true;
@@ -127,14 +129,13 @@ bool ServerConnection::addPendingTextureRequest(const wstring &textureName)
void ServerConnection::handleTextureReceived(const wstring &textureName)
{
- AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
- if( it != m_pendingTextureRequests.end() )
+ auto it = find(m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName);
+ if( it != m_pendingTextureRequests.end() )
{
m_pendingTextureRequests.erase(it);
}
- for (unsigned int i = 0; i < players.size(); i++)
+ for (auto& player : players)
{
- shared_ptr<PlayerConnection> player = players[i];
if (!player->done)
{
player->handleTextureReceived(textureName);
@@ -144,14 +145,13 @@ void ServerConnection::handleTextureReceived(const wstring &textureName)
void ServerConnection::handleTextureAndGeometryReceived(const wstring &textureName)
{
- AUTO_VAR(it, find( m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName));
- if( it != m_pendingTextureRequests.end() )
+ auto it = find(m_pendingTextureRequests.begin(), m_pendingTextureRequests.end(), textureName);
+ if( it != m_pendingTextureRequests.end() )
{
m_pendingTextureRequests.erase(it);
}
- for (unsigned int i = 0; i < players.size(); i++)
+ for (auto& player : players)
{
- shared_ptr<PlayerConnection> player = players[i];
if (!player->done)
{
player->handleTextureAndGeometryReceived(textureName);
@@ -172,7 +172,7 @@ void ServerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
app.DebugPrintf("ClientConnection::handleServerSettingsChanged - Difficulty = %d",packet->data);
pMinecraft->levels[i]->difficulty = packet->data;
}
- }
+ }
}
// else if(packet->action==ServerSettingsChangedPacket::HOST_IN_GAME_SETTINGS)// options
// {
@@ -190,11 +190,11 @@ void ServerConnection::handleServerSettingsChanged(shared_ptr<ServerSettingsChan
// {
// pMinecraft->options->SetGamertagSetting(false);
// }
-//
+//
// for (unsigned int i = 0; i < players.size(); i++)
// {
// shared_ptr<PlayerConnection> playerconnection = players[i];
-// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
+// playerconnection->setShowOnMaps(pMinecraft->options->GetGamertagSetting());
// }
// }
}