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 a9be52c41a.
This commit is contained in:
Loki Rautio
2026-03-07 21:12:22 -06:00
parent a9be52c41a
commit 087b7e7abf
1373 changed files with 19449 additions and 19903 deletions

View File

@@ -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<73>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<73>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 {