From 393cce885bf62048c7722215fa17507979c78b56 Mon Sep 17 00:00:00 2001 From: Jett <55758076+Jettford@users.noreply.github.com> Date: Tue, 7 Dec 2021 11:12:29 +0000 Subject: [PATCH] Windows fixes - "Fixed" segfault - Fixed logger not actually logging time --- dCommon/dLogger.cpp | 4 ++-- dNet/WorldPackets.cpp | 21 ++++++++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/dCommon/dLogger.cpp b/dCommon/dLogger.cpp index 4cd9655a..6ee0e7d2 100644 --- a/dCommon/dLogger.cpp +++ b/dCommon/dLogger.cpp @@ -92,8 +92,8 @@ void dLogger::Log(const char * className, const char * format, ...) { va_end(args); - if (m_logToConsole) std::cout << "[" << "timeStr" << "] [" << className << "]: " << message; - mFile << "[" << "timeStr" << "] [" << className << "]: " << message; + if (m_logToConsole) std::cout << "[" << timeStr << "] [" << className << "]: " << message; + mFile << "[" << timeStr << "] [" << className << "]: " << message; #else time_t t = time(NULL); struct tm * time = localtime(&t); diff --git a/dNet/WorldPackets.cpp b/dNet/WorldPackets.cpp index 67c20c03..399ab9e5 100644 --- a/dNet/WorldPackets.cpp +++ b/dNet/WorldPackets.cpp @@ -153,27 +153,26 @@ void WorldPackets::SendCreateCharacter(const SystemAddress& sysAddr, const LWOOB delete gmlevel; delete chatmode; delete name; - + +#ifdef _WIN32 + bitStream.Write(data.GetNumberOfBytesUsed() + 1); + bitStream.Write(0); + bitStream.Write((char*)data.GetData(), data.GetNumberOfBytesUsed()); +#else //Compress the data before sending: const int reservedSize = 5 * 1024 * 1024; uint8_t compressedData[reservedSize]; size_t size = ZCompression::Compress(data.GetData(), data.GetNumberOfBytesUsed(), compressedData, reservedSize); bitStream.Write(size + 9); //size of data + header bytes (8) - bitStream.Write(1); //compressed boolean, true + bitStream.Write(1); //compressed boolean, true bitStream.Write(data.GetNumberOfBytesUsed()); bitStream.Write(size); - + for (size_t i = 0; i < size; i++) bitStream.Write(compressedData[i]); - - /* - uint32_t dataSize = data.GetNumberOfBytesUsed(); - bitStream.Write(dataSize + 8); // The data size - bitStream.Write(static_cast(0)); // Data is not compressed - bitStream.Write(data); // Write the data - */ - +#endif + PacketUtils::SavePacket("chardata.bin", (const char *)bitStream.GetData(), static_cast(bitStream.GetNumberOfBytesUsed())); SEND_PACKET Game::logger->Log("WorldPackets", "Sent CreateCharacter for ID: %llu\n", objectID);