aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.World/Connection.cpp
diff options
context:
space:
mode:
authorLoki Rautio <lokirautio@gmail.com>2026-03-07 21:12:22 -0600
committerLoki Rautio <lokirautio@gmail.com>2026-03-07 21:12:22 -0600
commit087b7e7abfe81dd7f0fdcdea36ac9f245950df1a (patch)
tree69454763e73ca764af4e682d3573080b13138a0e /Minecraft.World/Connection.cpp
parenta9be52c41a02d207233199e98898fe7483d7e817 (diff)
Revert "Project modernization (#630)"
This code was not tested and breaks in Release builds, reverting to restore functionality of the nightly. All in-game menus do not work and generating a world crashes. This reverts commit a9be52c41a02d207233199e98898fe7483d7e817.
Diffstat (limited to 'Minecraft.World/Connection.cpp')
-rw-r--r--Minecraft.World/Connection.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/Minecraft.World/Connection.cpp b/Minecraft.World/Connection.cpp
index 4015d8f6..09f72be0 100644
--- a/Minecraft.World/Connection.cpp
+++ b/Minecraft.World/Connection.cpp
@@ -61,17 +61,17 @@ Connection::~Connection()
// These should all have been destroyed in close() but no harm in checking again
delete byteArrayDos;
- byteArrayDos = nullptr;
+ byteArrayDos = NULL;
delete baos;
- baos = nullptr;
+ baos = NULL;
if( bufferedDos )
{
bufferedDos->deleteChildStream();
delete bufferedDos;
- bufferedDos = nullptr;
+ bufferedDos = NULL;
}
delete dis;
- dis = nullptr;
+ dis = NULL;
}
Connection::Connection(Socket *socket, const wstring& id, PacketListener *packetListener) // throws IOException
@@ -111,7 +111,7 @@ Connection::Connection(Socket *socket, const wstring& id, PacketListener *packet
sprintf(readThreadName,"%s read\n",szId);
sprintf(writeThreadName,"%s write\n",szId);
- readThread = new C4JThread(runRead, static_cast<void *>(this), readThreadName, READ_STACK_SIZE);
+ readThread = new C4JThread(runRead, (void*)this, readThreadName, READ_STACK_SIZE);
writeThread = new C4JThread(runWrite, this, writeThreadName, WRITE_STACK_SIZE);
readThread->SetProcessor(CPU_CORE_CONNECTIONS);
writeThread->SetProcessor(CPU_CORE_CONNECTIONS );
@@ -185,7 +185,7 @@ bool Connection::writeTick()
bool didSomething = false;
// 4J Stu - If the connection is closed and the output stream has been deleted
- if(bufferedDos==nullptr || byteArrayDos==nullptr)
+ if(bufferedDos==NULL || byteArrayDos==NULL)
return didSomething;
// try {
@@ -318,14 +318,14 @@ bool Connection::readTick()
bool didSomething = false;
// 4J Stu - If the connection has closed and the input stream has been deleted
- if(dis==nullptr)
+ if(dis==NULL)
return didSomething;
//try {
shared_ptr<Packet> packet = Packet::readPacket(dis, packetListener->isServerPacketListener());
- if (packet != nullptr)
+ if (packet != NULL)
{
readSizes[packet->getId()] += packet->getEstimatedSize() + 1;
EnterCriticalSection(&incoming_cs);
@@ -341,7 +341,7 @@ bool Connection::readTick()
// printf("Con:0x%x readTick close EOS\n",this);
// 4J Stu - Remove this line
- // Fix for #10410 - UI: If the player is removed from a splitscreened host�s game, the next game that player joins will produce a message stating that the host has left.
+ // Fix for #10410 - UI: If the player is removed from a splitscreened host’s game, the next game that player joins will produce a message stating that the host has left.
//close(DisconnectPacket::eDisconnect_EndOfStream);
}
@@ -377,8 +377,8 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
disconnectReason = reason;//va_arg( input, const wstring );
vector<void *> objs = vector<void *>();
- void *i = nullptr;
- while (i != nullptr)
+ void *i = NULL;
+ while (i != NULL)
{
i = va_arg( input, void* );
objs.push_back(i);
@@ -390,7 +390,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
}
else
{
- disconnectReasonObjects = nullptr;
+ disconnectReasonObjects = NULL;
}
// int count = 0, sum = 0, i = first;
@@ -407,7 +407,7 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
// return( sum ? (sum / count) : 0 );
-// CreateThread(nullptr, 0, runClose, this, 0, &closeThreadID);
+// CreateThread(NULL, 0, runClose, this, 0, &closeThreadID);
running = false;
@@ -419,24 +419,24 @@ void Connection::close(DisconnectPacket::eDisconnectReason reason, ...)
writeThread->WaitForCompletion(INFINITE);
delete dis;
- dis = nullptr;
+ dis = NULL;
if( bufferedDos )
{
bufferedDos->close();
bufferedDos->deleteChildStream();
delete bufferedDos;
- bufferedDos = nullptr;
+ bufferedDos = NULL;
}
if( byteArrayDos )
{
byteArrayDos->close();
delete byteArrayDos;
- byteArrayDos = nullptr;
+ byteArrayDos = NULL;
}
if( socket )
{
socket->close(packetListener->isServerPacketListener());
- socket = nullptr;
+ socket = NULL;
}
}
@@ -473,7 +473,7 @@ void Connection::tick()
tickCount++;
if (tickCount % 20 == 0)
{
- send(std::make_shared<KeepAlivePacket>());
+ send( shared_ptr<KeepAlivePacket>( new KeepAlivePacket() ) );
}
// 4J Stu - 1.8.2 changed from 100 to 1000
@@ -498,7 +498,7 @@ void Connection::tick()
LeaveCriticalSection(&incoming_cs);
// MGH - moved the packet handling outside of the incoming_cs block, as it was locking up sometimes when disconnecting
- for(size_t i = 0; i < packetsToHandle.size(); i++)
+ for(int i=0; i<packetsToHandle.size();i++)
{
PIXBeginNamedEvent(0,"Handling packet %d\n",packetsToHandle[i]->getId());
packetsToHandle[i]->handle(packetListener);
@@ -552,22 +552,22 @@ void Connection::sendAndQuit()
close(DisconnectPacket::eDisconnect_Closed);
}
#else
- CreateThread(nullptr, 0, runSendAndQuit, this, 0, &saqThreadID);
+ CreateThread(NULL, 0, runSendAndQuit, this, 0, &saqThreadID);
#endif
}
int Connection::countDelayedPackets()
{
- return static_cast<int>(outgoing_slow.size());
+ return (int)outgoing_slow.size();
}
int Connection::runRead(void* lpParam)
{
ShutdownManager::HasStarted(ShutdownManager::eConnectionReadThreads);
- Connection *con = static_cast<Connection *>(lpParam);
+ Connection *con = (Connection *)lpParam;
- if (con == nullptr)
+ if (con == NULL)
{
#ifdef __PS3__
ShutdownManager::HasFinished(ShutdownManager::eConnectionReadThreads);
@@ -615,9 +615,9 @@ int Connection::runRead(void* lpParam)
int Connection::runWrite(void* lpParam)
{
ShutdownManager::HasStarted(ShutdownManager::eConnectionWriteThreads);
- Connection *con = dynamic_cast<Connection *>(static_cast<Connection *>(lpParam));
+ Connection *con = dynamic_cast<Connection *>((Connection *) lpParam);
- if (con == nullptr)
+ if (con == NULL)
{
ShutdownManager::HasFinished(ShutdownManager::eConnectionWriteThreads);
return 0;
@@ -644,8 +644,8 @@ int Connection::runWrite(void* lpParam)
// TODO - 4J Stu - 1.8.2 changes these sleeps to 2L, but not sure whether we should do that as well
waitResult = con->m_hWakeWriteThread->WaitForSignal(100L);
- if (con->bufferedDos != nullptr) con->bufferedDos->flush();
- //if (con->byteArrayDos != nullptr) con->byteArrayDos->flush();
+ if (con->bufferedDos != NULL) con->bufferedDos->flush();
+ //if (con->byteArrayDos != NULL) con->byteArrayDos->flush();
}
@@ -660,9 +660,9 @@ int Connection::runWrite(void* lpParam)
int Connection::runClose(void* lpParam)
{
- Connection *con = dynamic_cast<Connection *>(static_cast<Connection *>(lpParam));
+ Connection *con = dynamic_cast<Connection *>((Connection *) lpParam);
- if (con == nullptr) return 0;
+ if (con == NULL) return 0;
//try {
@@ -683,10 +683,10 @@ int Connection::runClose(void* lpParam)
int Connection::runSendAndQuit(void* lpParam)
{
- Connection *con = dynamic_cast<Connection *>(static_cast<Connection *>(lpParam));
+ Connection *con = dynamic_cast<Connection *>((Connection *) lpParam);
// printf("Con:0x%x runSendAndQuit\n",con);
- if (con == nullptr) return 0;
+ if (con == NULL) return 0;
//try {