diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index badb1c24..00000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "Minecraft.Server"] - path = Minecraft.Server - url = https://gitea.str1k3r.xyz/cafeberry/Cafeberry-Server.git diff --git a/Minecraft.Client/Common/Consoles_App.cpp b/Minecraft.Client/Common/Consoles_App.cpp index d5c29b8c..56a374d7 100644 --- a/Minecraft.Client/Common/Consoles_App.cpp +++ b/Minecraft.Client/Common/Consoles_App.cpp @@ -1,7 +1,5 @@  #include "stdafx.h" - -#include #include "..\..\Minecraft.World\net.minecraft.world.entity.item.h" #include "..\..\Minecraft.World\net.minecraft.world.entity.player.h" #include "..\..\Minecraft.World\net.minecraft.world.level.tile.entity.h" @@ -238,26 +236,6 @@ void CMinecraftApp::DebugPrintf(const char *szFormat, ...) vsnprintf(buf, sizeof(buf), szFormat, ap); va_end(ap); OutputDebugStringA(buf); -#ifdef _DEDICATED_SERVER - bool hasContent = false; - for (const char *p = buf; *p; p++) { - if (*p != ' ' && *p != '\t' && *p != '\n' && *p != '\r' && *p != '=') { - hasContent = true; - break; - } - } - if (hasContent) - { - size_t len = strlen(buf); - while (len > 0 && (buf[len-1] == '\n' || buf[len-1] == '\r')) - buf[--len] = '\0'; - - time_t now = time(NULL); - struct tm t; - localtime_s(&t, &now); - printf("[%02d:%02d:%02d] [Server thread/INFO]: %s\n", t.tm_hour, t.tm_min, t.tm_sec, buf); - } -#endif #endif } @@ -320,9 +298,6 @@ LPCWSTR CMinecraftApp::GetString(int iID) { //return L"DeÄŸiÅŸiklikler ve Yenilikler"; //return L"ÕÕÕÕÖÖÖÖ"; -#ifdef _DEDICATED_SERVER - if (!app.m_stringTable) return L""; -#endif return app.m_stringTable->getString(iID); } diff --git a/Minecraft.Client/Common/Network/GameNetworkManager.cpp b/Minecraft.Client/Common/Network/GameNetworkManager.cpp index bde8e013..f422c3a0 100644 --- a/Minecraft.Client/Common/Network/GameNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/GameNetworkManager.cpp @@ -873,14 +873,12 @@ int CGameNetworkManager::JoinFromInvite_SignInReturned(void *pParam,bool bContin void CGameNetworkManager::UpdateAndSetGameSessionData(INetworkPlayer *pNetworkPlayerLeaving) { -#ifndef _DEDICATED_SERVER Minecraft *pMinecraft = Minecraft::GetInstance(); TexturePack *tPack = pMinecraft->skins->getSelected(); s_pPlatformNetworkManager->SetSessionTexturePackParentId( tPack->getDLCParentPackId() ); s_pPlatformNetworkManager->SetSessionSubTexturePackId( tPack->getDLCSubPackId() ); s_pPlatformNetworkManager->UpdateAndSetGameSessionData( pNetworkPlayerLeaving ); -#endif } void CGameNetworkManager::SendInviteGUI(int quadrant) @@ -1542,7 +1540,6 @@ void CGameNetworkManager::CreateSocket( INetworkPlayer *pNetworkPlayer, bool loc // Add this user to the game server if the game is started already if( g_NetworkManager.IsHost() && g_NetworkManager.IsInGameplay() ) { - app.DebugPrintf("Adding incoming socket for smallId=%d\n", pNetworkPlayer->GetSmallId()); Socket::addIncomingSocket(socket); } diff --git a/Minecraft.Client/Common/Network/NetworkSocketLayer.cpp b/Minecraft.Client/Common/Network/NetworkSocketLayer.cpp index 9536e272..fba5a944 100644 --- a/Minecraft.Client/Common/Network/NetworkSocketLayer.cpp +++ b/Minecraft.Client/Common/Network/NetworkSocketLayer.cpp @@ -61,9 +61,6 @@ std::vector NetworkSocketLayer::s_pendingJoinSmallIds; CRITICAL_SECTION NetworkSocketLayer::s_freeSmallIdLock; std::vector NetworkSocketLayer::s_freeSmallIds; -CRITICAL_SECTION NetworkSocketLayer::s_earlyDataLock; -std::vector NetworkSocketLayer::s_earlyDataBuffers[NETWORK_LAN_MAX_CLIENTS + 1]; - // only goes true on a successful Initialize(), and a failed one gets retried static bool s_locksCreated = false; #if defined _WINDOWS64 @@ -91,7 +88,6 @@ bool NetworkSocketLayer::Initialize() InitializeCriticalSection(&s_disconnectLock); InitializeCriticalSection(&s_pendingJoinLock); InitializeCriticalSection(&s_freeSmallIdLock); - InitializeCriticalSection(&s_earlyDataLock); for (int i = 0; i < NETWORK_LAN_MAX_CLIENTS + 1; i++) { @@ -143,9 +139,7 @@ bool NetworkSocketLayer::Initialize() s_initialized = true; -#ifndef _DEDICATED_SERVER StartDiscovery(); -#endif return true; } @@ -807,9 +801,6 @@ bool NetworkSocketLayer::JoinGame(const char *ip, int port) } s_localSmallId = assignedSmallId; - DWORD noTimeout = 0; - setsockopt(s_hostConnectionSocket, SOL_SOCKET, SO_RCVTIMEO, (const char *)&noTimeout, sizeof(noTimeout)); - app.DebugPrintf("LAN: Connected to %s:%d, assigned smallId=%d\n", ip, port, s_localSmallId); s_active = true; @@ -935,13 +926,9 @@ void NetworkSocketLayer::HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, un if (pPlayerFrom == NULL || pPlayerTo == NULL) { - if (s_isHost && fromSmallId > 0 && fromSmallId < NETWORK_LAN_MAX_CLIENTS + 1) - { - EnterCriticalSection(&s_earlyDataLock); - s_earlyDataBuffers[fromSmallId].insert( - s_earlyDataBuffers[fromSmallId].end(), data, data + dataSize); - LeaveCriticalSection(&s_earlyDataLock); - } + // dropping here is silent and looks identical to the peer never sending + app.DebugPrintf("LAN: DROPPED %u bytes - from smallId=%d(%s) to smallId=%d(%s)\n", + dataSize, fromSmallId, pPlayerFrom ? "ok" : "NULL", toSmallId, pPlayerTo ? "ok" : "NULL"); return; } @@ -950,13 +937,6 @@ void NetworkSocketLayer::HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, un ::Socket *pSocket = pPlayerFrom->GetSocket(); if (pSocket != NULL) pSocket->pushDataToQueue(data, dataSize, false); - else - { - EnterCriticalSection(&s_earlyDataLock); - s_earlyDataBuffers[fromSmallId].insert( - s_earlyDataBuffers[fromSmallId].end(), data, data + dataSize); - LeaveCriticalSection(&s_earlyDataLock); - } } else { @@ -966,26 +946,6 @@ void NetworkSocketLayer::HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, un } } -void NetworkSocketLayer::FlushPendingData() -{ - EnterCriticalSection(&s_earlyDataLock); - for (int i = 1; i < NETWORK_LAN_MAX_CLIENTS + 1; i++) - { - if (s_earlyDataBuffers[i].empty()) continue; - - INetworkPlayer *pPlayer = g_NetworkManager.GetPlayerBySmallId((BYTE)i); - if (pPlayer == NULL) continue; - - ::Socket *pSocket = pPlayer->GetSocket(); - if (pSocket == NULL) continue; - - pSocket->pushDataToQueue(s_earlyDataBuffers[i].data(), - (DWORD)s_earlyDataBuffers[i].size(), false); - s_earlyDataBuffers[i].clear(); - } - LeaveCriticalSection(&s_earlyDataLock); -} - int NetworkSocketLayer::AcceptThreadProc(LPVOID param) { while (s_active) @@ -1212,11 +1172,6 @@ void NetworkSocketLayer::CloseConnectionBySmallId(BYTE smallId) app.DebugPrintf("Win64 LAN: Force-closed TCP connection for smallId=%d\n", smallId); } LeaveCriticalSection(&s_connectionsLock); - - EnterCriticalSection(&s_earlyDataLock); - if (smallId < NETWORK_LAN_MAX_CLIENTS + 1) - s_earlyDataBuffers[smallId].clear(); - LeaveCriticalSection(&s_earlyDataLock); } int NetworkSocketLayer::ClientRecvThreadProc(LPVOID param) @@ -1288,11 +1243,6 @@ bool NetworkSocketLayer::StartAdvertising(int gamePort, const wchar_t *hostName, s_advertiseData.texturePackParentId = texPackId; s_advertiseData.subTexturePackId = subTexId; s_advertiseData.isJoinable = 0; -#ifdef _DEDICATED_SERVER - s_advertiseData.isDedicatedServer = 1; -#else - s_advertiseData.isDedicatedServer = 0; -#endif s_hostGamePort = gamePort; LeaveCriticalSection(&s_advertiseLock); @@ -1673,7 +1623,6 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param) s_discoveredSessions[i].texturePackParentId = broadcast->texturePackParentId; s_discoveredSessions[i].subTexturePackId = broadcast->subTexturePackId; s_discoveredSessions[i].isJoinable = (broadcast->isJoinable != 0); - s_discoveredSessions[i].isDedicatedServer = (broadcast->isDedicatedServer != 0); s_discoveredSessions[i].lastSeenTick = now; memcpy(s_discoveredSessions[i].playerNames, broadcast->playerNames, sizeof(broadcast->playerNames)); found = true; @@ -1707,7 +1656,6 @@ int NetworkSocketLayer::DiscoveryThreadProc(LPVOID param) session.texturePackParentId = broadcast->texturePackParentId; session.subTexturePackId = broadcast->subTexturePackId; session.isJoinable = (broadcast->isJoinable != 0); - session.isDedicatedServer = (broadcast->isDedicatedServer != 0); session.lastSeenTick = now; memcpy(session.playerNames, broadcast->playerNames, sizeof(broadcast->playerNames)); s_discoveredSessions.push_back(session); diff --git a/Minecraft.Client/Common/Network/NetworkSocketLayer.h b/Minecraft.Client/Common/Network/NetworkSocketLayer.h index d3221ce7..908a4b61 100644 --- a/Minecraft.Client/Common/Network/NetworkSocketLayer.h +++ b/Minecraft.Client/Common/Network/NetworkSocketLayer.h @@ -116,7 +116,6 @@ struct LANBroadcast DWORD texturePackParentId; BYTE subTexturePackId; BYTE isJoinable; - BYTE isDedicatedServer; char playerNames[NETWORK_LAN_BROADCAST_PLAYERS][NETWORK_LAN_PLAYER_NAME_SIZE]; }; #pragma pack(pop) @@ -133,7 +132,6 @@ struct LANSession unsigned int texturePackParentId; unsigned char subTexturePackId; bool isJoinable; - bool isDedicatedServer; DWORD lastSeenTick; char playerNames[NETWORK_LAN_BROADCAST_PLAYERS][NETWORK_LAN_PLAYER_NAME_SIZE]; }; @@ -169,7 +167,6 @@ public: static SOCKET GetSocketForSmallId(BYTE smallId); static void HandleDataReceived(BYTE fromSmallId, BYTE toSmallId, unsigned char *data, unsigned int dataSize); - static void FlushPendingData(); static bool PopDisconnectedSmallId(BYTE *outSmallId); static void PushFreeSmallId(BYTE smallId); @@ -238,9 +235,6 @@ private: static CRITICAL_SECTION s_freeSmallIdLock; static std::vector s_freeSmallIds; - - static CRITICAL_SECTION s_earlyDataLock; - static std::vector s_earlyDataBuffers[NETWORK_LAN_MAX_CLIENTS + 1]; }; extern bool g_MultiplayerHost; diff --git a/Minecraft.Client/Common/Network/PlatformNetworkManager.cpp b/Minecraft.Client/Common/Network/PlatformNetworkManager.cpp index bbbe7638..968ff578 100644 --- a/Minecraft.Client/Common/Network/PlatformNetworkManager.cpp +++ b/Minecraft.Client/Common/Network/PlatformNetworkManager.cpp @@ -354,10 +354,6 @@ bool CPlatformNetworkManagerStub::LeaveGame(bool bMigrateHost) if( m_bLeavingGame ) return true; m_bLeavingGame = true; - - extern bool g_connectedToDedicatedServer; - g_connectedToDedicatedServer = false; - NetworkSocketLayer::StopAdvertising(); // If we are the host wait for the game server to end @@ -407,10 +403,10 @@ void CPlatformNetworkManagerStub::HostGame(int localUsersMask, bool bOnlineGame, IQNet::m_player[0].m_smallId = 0; IQNet::m_player[0].m_isRemote = false; IQNet::m_player[0].m_isHostPlayer = true; - IQNet::s_playerCount = 1; -#if defined _WINDOWS64 && !defined WITH_SERVER_CODE +#ifdef _WINDOWS64 extern wchar_t g_Win64UsernameW[17]; wcscpy_s(IQNet::m_player[0].m_gamertag, 32, g_Win64UsernameW); + IQNet::s_playerCount = 1; #endif if (getNetworkPlayer(&IQNet::m_player[0]) == NULL) @@ -458,9 +454,6 @@ int CPlatformNetworkManagerStub::JoinGame(FriendSessionInfo *searchResult, int l wcsncpy(IQNet::m_player[0].m_gamertag, searchResult->data.hostName, 31); IQNet::m_player[0].m_gamertag[31] = L'\0'; - extern bool g_connectedToDedicatedServer; - g_connectedToDedicatedServer = searchResult->data.isDedicatedServer; - NetworkSocketLayer::StopDiscovery(); if (!NetworkSocketLayer::JoinGame(hostIP, hostPort)) @@ -808,7 +801,6 @@ void CPlatformNetworkManagerStub::SearchForGames() info->data.subTexturePackId = lanSessions[i].subTexturePackId; info->data.isReadyToJoin = lanSessions[i].isJoinable; info->data.isJoinable = lanSessions[i].isJoinable; - info->data.isDedicatedServer = lanSessions[i].isDedicatedServer; strncpy(info->data.hostIP, lanSessions[i].hostIP, sizeof(info->data.hostIP) - 1); info->data.hostIP[sizeof(info->data.hostIP) - 1] = '\0'; info->data.hostPort = lanSessions[i].hostPort; diff --git a/Minecraft.Client/Common/Network/SessionInfo.h b/Minecraft.Client/Common/Network/SessionInfo.h index 1844950e..eb9a42a6 100644 --- a/Minecraft.Client/Common/Network/SessionInfo.h +++ b/Minecraft.Client/Common/Network/SessionInfo.h @@ -79,7 +79,6 @@ typedef struct _GameSessionData bool isReadyToJoin; // 1 byte bool isJoinable; // 1 byte - bool isDedicatedServer; // 1 byte char hostIP[64]; // 64 bytes int hostPort; // 4 bytes @@ -98,7 +97,6 @@ typedef struct _GameSessionData subTexturePackId = 0; isReadyToJoin = false; isJoinable = true; - isDedicatedServer = false; memset(hostIP, 0, sizeof(hostIP)); hostPort = 0; memset(hostName, 0, sizeof(hostName)); diff --git a/Minecraft.Client/Extrax64Stubs.cpp b/Minecraft.Client/Extrax64Stubs.cpp index 2d62be5d..2d50b945 100644 --- a/Minecraft.Client/Extrax64Stubs.cpp +++ b/Minecraft.Client/Extrax64Stubs.cpp @@ -547,8 +547,6 @@ bool IQNet::s_isHosting = true; QNET_STATE _iQNetStubState = QNET_STATE_IDLE; -bool g_connectedToDedicatedServer = false; - void Win64_SetupRemoteQNetPlayer(IQNetPlayer *player, BYTE smallId, bool isHost, bool isLocal) { player->m_smallId = smallId; @@ -599,13 +597,7 @@ IQNetPlayer *IQNet::GetLocalPlayerByUserIndex(DWORD dwUserIndex) } static bool Win64_IsActivePlayer(IQNetPlayer *p, DWORD index) { - if (index == 0) - { - extern bool g_connectedToDedicatedServer; - if (g_connectedToDedicatedServer && !IQNet::s_isHosting) - return false; - return true; - } + if (index == 0) return true; if (p->GetCustomDataValue() != 0) return true; return (p->m_isRemote && p->m_gamertag[0] != 0); } diff --git a/Minecraft.Client/Minecraft.cpp b/Minecraft.Client/Minecraft.cpp index f8dd53b1..96111185 100644 --- a/Minecraft.Client/Minecraft.cpp +++ b/Minecraft.Client/Minecraft.cpp @@ -4963,18 +4963,11 @@ void Minecraft::handleClientTextureReceived(const wstring &textureName) unsigned int Minecraft::getCurrentTexturePackId() { -#ifdef _DEDICATED_SERVER - return 0; -#else return skins->getSelected()->getId(); -#endif } ColourTable *Minecraft::getColourTable() { -#ifdef _DEDICATED_SERVER - return NULL; -#else TexturePack *selected = skins->getSelected(); ColourTable *colours = selected->getColourTable(); @@ -4985,7 +4978,6 @@ ColourTable *Minecraft::getColourTable() } return colours; -#endif } #if defined __ORBIS__ diff --git a/Minecraft.Client/MinecraftServer.cpp b/Minecraft.Client/MinecraftServer.cpp index 67f5e027..626b5d08 100644 --- a/Minecraft.Client/MinecraftServer.cpp +++ b/Minecraft.Client/MinecraftServer.cpp @@ -35,11 +35,7 @@ #include "..\Minecraft.World\net.minecraft.world.entity.h" #include "ProgressRenderer.h" #include "ServerPlayer.h" -#include "PlayerConnection.h" #include "GameRenderer.h" -#if defined(_WINDOWS64) || defined(DISABLE_PSN) || defined(_DISABLE_XBLIVE) -#include "Common\Network\NetworkSocketLayer.h" -#endif #include "..\Minecraft.World\ThreadName.h" #include "..\Minecraft.World\IntCache.h" #include "..\Minecraft.World\CompressedTileStorage.h" @@ -51,11 +47,6 @@ #endif #include "PS3\PS3Extras\ShutdownManager.h" #include "ServerCommandDispatcher.h" - -#ifdef _DEDICATED_SERVER -#include "..\Minecraft.Server\Commands\ServerCommands.h" -#endif - #include "..\Minecraft.World\BiomeSource.h" #include "PlayerChunkMap.h" #include "Common\Telemetry\TelemetryManager.h" @@ -159,11 +150,13 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW #endif settings = new Settings(new File(L"server.properties")); - app.DebugPrintf("host-friends-only is %s",(app.GetGameHostOption(eGameHostOption_FriendsOfFriends)>0)?"on":"off"); - app.DebugPrintf("game-type is %s",(app.GetGameHostOption(eGameHostOption_GameType)==0)?"Survival Mode":"Creative Mode"); - app.DebugPrintf("pvp is %s",(app.GetGameHostOption(eGameHostOption_PvP)>0)?"on":"off"); - app.DebugPrintf("fire-spreads is %s",(app.GetGameHostOption(eGameHostOption_FireSpreads)>0)?"on":"off"); - app.DebugPrintf("tnt-explodes is %s",(app.GetGameHostOption(eGameHostOption_TNT)>0)?"on":"off"); + app.DebugPrintf("\n*** SERVER SETTINGS ***\n"); + app.DebugPrintf("ServerSettings: host-friends-only is %s\n",(app.GetGameHostOption(eGameHostOption_FriendsOfFriends)>0)?"on":"off"); + app.DebugPrintf("ServerSettings: game-type is %s\n",(app.GetGameHostOption(eGameHostOption_GameType)==0)?"Survival Mode":"Creative Mode"); + app.DebugPrintf("ServerSettings: pvp is %s\n",(app.GetGameHostOption(eGameHostOption_PvP)>0)?"on":"off"); + app.DebugPrintf("ServerSettings: fire spreads is %s\n",(app.GetGameHostOption(eGameHostOption_FireSpreads)>0)?"on":"off"); + app.DebugPrintf("ServerSettings: tnt explodes is %s\n",(app.GetGameHostOption(eGameHostOption_TNT)>0)?"on":"off"); + app.DebugPrintf("\n"); // TODO 4J Stu - Init a load of settings based on data passed as params //settings->setBooleanAndSave( L"host-friends-only", (app.GetGameHostOption(eGameHostOption_FriendsOfFriends)>0) ); @@ -290,14 +283,6 @@ bool MinecraftServer::initServer(__int64 seed, NetworkGameInitData *initData, DW } g_NetworkManager.ServerReady(); // 4J added - -#ifdef _DEDICATED_SERVER - { - extern QNET_STATE _iQNetStubState; - _iQNetStubState = QNET_STATE_GAME_PLAY; - } -#endif - return m_bLoaded; } @@ -420,7 +405,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring int gameTypeId = settings->getInt(L"gamemode", app.GetGameHostOption(eGameHostOption_GameType));//LevelSettings::GAMETYPE_SURVIVAL); GameType *gameType = LevelSettings::validateGameType(gameTypeId); - app.DebugPrintf("Default game type: %d" , gameTypeId); + app.DebugPrintf("Default game type: %d\n" , gameTypeId); LevelSettings *levelSettings = new LevelSettings(levelSeed, gameType, app.GetGameHostOption(eGameHostOption_Structures)>0?true:false, isHardcore(), true, pLevelType, initData->xzSize, initData->hellScale); if( app.GetGameHostOption(eGameHostOption_BonusChest ) ) levelSettings->enableStartingBonusItems(); @@ -512,7 +497,7 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring Minecraft *pMinecraft = Minecraft::GetInstance(); // m_lastSentDifficulty = pMinecraft->options->difficulty; levels[i]->difficulty = app.GetGameHostOption(eGameHostOption_Difficulty); //pMinecraft->options->difficulty; - app.DebugPrintf("MinecraftServer::loadLevel - Difficulty = %d",levels[i]->difficulty); + app.DebugPrintf("MinecraftServer::loadLevel - Difficulty = %d\n",levels[i]->difficulty); #if DEBUG_SERVER_DONT_SPAWN_MOBS levels[i]->setSpawnSettings(false, false); @@ -586,13 +571,6 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring csf->closeHandle(fe); } -#ifdef _DEDICATED_SERVER - { - __int64 doneTime = System::currentTimeMillis(); - app.DebugPrintf("Done! For help, type \"help\" or \"?\""); - } -#endif - __int64 lastTime = System::currentTimeMillis(); #ifdef _LARGE_WORLDS if(app.GetGameNewWorldSize() > levels[0]->getLevelData()->getXZSizeOld()) @@ -715,6 +693,9 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring // stronghold position? if(levels[0]->dimension->id==0) { + + app.DebugPrintf("===================================\n"); + if(!levels[0]->getLevelData()->getHasStronghold()) { int x,z; @@ -724,19 +705,20 @@ bool MinecraftServer::loadLevel(LevelStorageSource *storageSource, const wstring levels[0]->getLevelData()->setZStronghold(z); levels[0]->getLevelData()->setHasStronghold(); - app.DebugPrintf("FOUND stronghold in terrain features list\n"); + app.DebugPrintf("=== FOUND stronghold in terrain features list\n"); } else { // can't find the stronghold position in the terrain feature list. Do we have to run a post-process? - app.DebugPrintf("Can't find stronghold in terrain features list\n"); + app.DebugPrintf("=== Can't find stronghold in terrain features list\n"); } } else { - app.DebugPrintf("Leveldata has stronghold position\n"); + app.DebugPrintf("=== Leveldata has stronghold position\n"); } + app.DebugPrintf("===================================\n"); } // printf("Post processing complete at %dms\n",System::currentTimeMillis() - startTime); @@ -1006,16 +988,12 @@ void MinecraftServer::stopServer(bool didInit) // 4J-PB - If the primary player has signed out, then don't attempt to save anything // also need to check for a profile switch here - primary player signs out, and another player signs in before dismissing the dash -#ifdef _DEDICATED_SERVER - { - { -#elif defined(_DURANGO) +#ifdef _DURANGO // On Durango check if the primary user is signed in OR mid-sign-out if(ProfileManager.GetUser(0, true) != nullptr) #else if((m_bPrimaryPlayerSignedOut==false) && ProfileManager.IsSignedIn(ProfileManager.GetPrimaryPad())) #endif -#ifndef _DEDICATED_SERVER { #if defined(_XBOX_ONE) || defined(__ORBIS__) // Always save on exit! Except if saves are disabled. @@ -1024,7 +1002,6 @@ void MinecraftServer::stopServer(bool didInit) // if trial version or saving is disabled, then don't save anything. Also don't save anything if we didn't actually get through the server initialisation. if(m_saveOnExit && ProfileManager.IsFullVersion() && (!StorageManager.GetSaveDisabled()) && didInit) { -#endif if (players != NULL) { players->saveAll(Minecraft::GetInstance()->progressRenderer, true); @@ -1634,33 +1611,6 @@ void MinecraftServer::tick() tickCount++; -#ifdef _DEDICATED_SERVER - if (tickCount % 6000 == 0 && !s_bServerHalted) - { - app.DebugPrintf("Auto-saving world...\n"); - if (players != NULL) - { - players->saveAll(NULL); - } - for (unsigned int j = 0; j < levels.length; j++) - { - if (s_bServerHalted) break; - ServerLevel *level = levels[levels.length - 1 - j]; - if (level) level->save(false, NULL, true); - } - if (!s_bServerHalted) - { - saveGameRules(); - levels[0]->saveToDisc(NULL, true); - } - while (StorageManager.GetSaveState() != C4JStorage::ESaveGame_Idle) - { - Sleep(10); - } - app.DebugPrintf("Auto-save complete\n"); - } -#endif - // 4J We need to update client difficulty levels based on the servers Minecraft *pMinecraft = Minecraft::GetInstance(); // 4J-PB - sending this on the host changing the difficulty in the menus @@ -1733,10 +1683,6 @@ void MinecraftServer::tick() } } Entity::tickExtraWandering(); // 4J added -#ifdef _DEDICATED_SERVER - g_NetworkManager.DoWork(); - NetworkSocketLayer::FlushPendingData(); -#endif PIXBeginNamedEvent(0,"Connection tick"); connection->tick(); @@ -1771,12 +1717,6 @@ void MinecraftServer::handleConsoleInputs() AUTO_VAR(it, consoleInput.begin()); ConsoleInput *input = *it; consoleInput.erase(it); -#ifdef _DEDICATED_SERVER - HandleServerCommand(input->msg, input->source, this); - delete input; -#else - delete input; -#endif // commands->handleCommand(input); // 4J - removed - TODO - do we want equivalent of console commands? } } diff --git a/Minecraft.Client/MultiPlayerChunkCache.cpp b/Minecraft.Client/MultiPlayerChunkCache.cpp index 879ebfd9..46c2a8d7 100644 --- a/Minecraft.Client/MultiPlayerChunkCache.cpp +++ b/Minecraft.Client/MultiPlayerChunkCache.cpp @@ -175,11 +175,10 @@ LevelChunk *MultiPlayerChunkCache::create(int x, int z) if (MinecraftServer::getInstance()->serverHalted()) return NULL; // If we're the host, then don't create the chunk, share data from the server's copy - int dimId = level->dimension->id; #ifdef _LARGE_WORLDS - LevelChunk *serverChunk = MinecraftServer::getInstance()->getLevel(dimId)->cache->getChunkLoadedOrUnloaded(x,z); + LevelChunk *serverChunk = MinecraftServer::getInstance()->getLevel(level->dimension->id)->cache->getChunkLoadedOrUnloaded(x,z); #else - LevelChunk *serverChunk = MinecraftServer::getInstance()->getLevel(dimId)->cache->getChunk(x,z); + LevelChunk *serverChunk = MinecraftServer::getInstance()->getLevel(level->dimension->id)->cache->getChunk(x,z); #endif chunk = new LevelChunk(level, x, z, serverChunk); // Let renderer know that this chunk has been created - it might have made render data from the EmptyChunk if it got to a chunk before the server sent it diff --git a/Minecraft.Client/PendingConnection.cpp b/Minecraft.Client/PendingConnection.cpp index f0959c65..873763e0 100644 --- a/Minecraft.Client/PendingConnection.cpp +++ b/Minecraft.Client/PendingConnection.cpp @@ -85,7 +85,6 @@ void PendingConnection::handlePreLogin(shared_ptr packet) return; } // printf("Server: handlePreLogin\n"); - app.DebugPrintf("PreLogin received from \"%ls\"\n", packet->loginKey.c_str()); name = packet->loginKey; // 4J Stu - Change from the login packet as we know better on client end during the pre-login packet sendPreLoginResponse(); } @@ -140,7 +139,6 @@ void PendingConnection::sendPreLoginResponse() void PendingConnection::handleLogin(shared_ptr packet) { - app.DebugPrintf("Login received from \"%ls\" (protocol %d)\n", name.c_str(), packet->clientVersion); // printf("Server: handleLogin\n"); //name = packet->userName; if (packet->clientVersion != SharedConstants::NETWORK_PROTOCOL_VERSION) diff --git a/Minecraft.Client/PlayerConnection.cpp b/Minecraft.Client/PlayerConnection.cpp index ed898895..9b5312d8 100644 --- a/Minecraft.Client/PlayerConnection.cpp +++ b/Minecraft.Client/PlayerConnection.cpp @@ -116,7 +116,7 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason) return; } - app.DebugPrintf("PlayerConnection disconect reason: %d", reason ); + app.DebugPrintf("PlayerConnection disconect reason: %d\n", reason ); player->disconnect(); // 4J Stu - Need to remove the player from the receiving list before their socket is NULLed so that we can find another player on their system @@ -543,16 +543,10 @@ void PlayerConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, if(getWasKicked()) { server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerKickedFromGame) ) ); -#ifdef _DEDICATED_SERVER - app.DebugPrintf("%ls was kicked from the game", player->name.c_str()); -#endif } else { server->getPlayers()->broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame) ) ); -#ifdef _DEDICATED_SERVER - app.DebugPrintf("%ls left the game", player->name.c_str()); -#endif } server->getPlayers()->remove(player); done = true; diff --git a/Minecraft.Client/PlayerConnection.h b/Minecraft.Client/PlayerConnection.h index 835d9bfe..39861f8c 100644 --- a/Minecraft.Client/PlayerConnection.h +++ b/Minecraft.Client/PlayerConnection.h @@ -1,4 +1,3 @@ -#pragma once #include "ConsoleInputSource.h" #include "..\Minecraft.World\PacketListener.h" #include "..\Minecraft.World\JavaIntHash.h" diff --git a/Minecraft.Client/PlayerList.cpp b/Minecraft.Client/PlayerList.cpp index dd44698e..08b01e62 100644 --- a/Minecraft.Client/PlayerList.cpp +++ b/Minecraft.Client/PlayerList.cpp @@ -243,10 +243,6 @@ void PlayerList::placeNewPlayer(Connection *connection, shared_ptr //server->players->broadcastAll( shared_ptr( new ChatPacket(L"§e" + playerEntity->name + L" joined the game.") ) ); broadcastAll( shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerJoinedGame) ) ); -#ifdef _DEDICATED_SERVER - app.DebugPrintf("%ls joined the game", player->name.c_str()); -#endif - MemSect(14); add(player); MemSect(0); diff --git a/Minecraft.Client/ServerChunkCache.cpp b/Minecraft.Client/ServerChunkCache.cpp index c8f84836..f26489e8 100644 --- a/Minecraft.Client/ServerChunkCache.cpp +++ b/Minecraft.Client/ServerChunkCache.cpp @@ -151,10 +151,8 @@ LevelChunk *ServerChunkCache::create(int x, int z, bool asyncPostProcess) // 4J if( ( chunk == NULL ) || ( chunk->x != x ) || ( chunk->z != z ) ) { - bool wasLoaded = false; EnterCriticalSection(&m_csLoadCreate); chunk = load(x, z); - wasLoaded = (chunk != NULL); if (chunk == NULL) { if (source == NULL) diff --git a/Minecraft.Client/ServerLevel.cpp b/Minecraft.Client/ServerLevel.cpp index a5570dab..1150c78b 100644 --- a/Minecraft.Client/ServerLevel.cpp +++ b/Minecraft.Client/ServerLevel.cpp @@ -1026,7 +1026,6 @@ void ServerLevel::saveToDisc(ProgressListener *progressListener, bool autosave) // 4J-PB - check that saves are enabled if(StorageManager.GetSaveDisabled()) return; -#ifndef _DEDICATED_SERVER // Check if we are using a trial version of a texture pack (which will be the case for going into the mash-up pack world with a trial version) if(!Minecraft::GetInstance()->skins->isUsingDefaultSkin()) { @@ -1040,7 +1039,6 @@ void ServerLevel::saveToDisc(ProgressListener *progressListener, bool autosave) return; } } -#endif if (progressListener != NULL) progressListener->progressStage(IDS_PROGRESS_SAVING_TO_DISC); levelStorage->flushSaveFile(autosave); diff --git a/Minecraft.Server b/Minecraft.Server deleted file mode 160000 index c356c7b9..00000000 --- a/Minecraft.Server +++ /dev/null @@ -1 +0,0 @@ -Subproject commit c356c7b911b45d4bc08bd5120a82007381da361a diff --git a/Minecraft.World/Level.cpp b/Minecraft.World/Level.cpp index 20740f4d..ec087554 100644 --- a/Minecraft.World/Level.cpp +++ b/Minecraft.World/Level.cpp @@ -1951,8 +1951,7 @@ AABBList *Level::getCubes(shared_ptr source, AABB *box, bool noEntities/ // 4J - now add in collision for any blocks which have actually been removed, but haven't had their render data updated to reflect this yet. This is to stop the player // being able to move the view position inside a tile which is (visually) still there, and see out of the world. This is particularly a problem when moving upwards in // creative mode as the player can get very close to the edge of tiles whilst looking upwards and can therefore very quickly move inside one. - if(Minecraft::GetInstance()->levelRenderer != NULL) - Minecraft::GetInstance()->levelRenderer->destroyedTileManager->addAABBs( this, box, &boxes); + Minecraft::GetInstance()->levelRenderer->destroyedTileManager->addAABBs( this, box, &boxes); // 4J - added if( noEntities ) return &boxes; diff --git a/Minecraft.World/OldChunkStorage.cpp b/Minecraft.World/OldChunkStorage.cpp index 7dbd4a86..bb87e39d 100644 --- a/Minecraft.World/OldChunkStorage.cpp +++ b/Minecraft.World/OldChunkStorage.cpp @@ -476,28 +476,29 @@ LevelChunk *OldChunkStorage::load(Level *level, DataInputStream *dis) CompoundTag *tag = NbtIo::read(dis); - if (tag != NULL) + loadEntities(levelChunk, level, tag); + + if (tag->contains(L"TileTicks")) { - loadEntities(levelChunk, level, tag); + PIXBeginNamedEvent(0,"Loading TileTicks"); + ListTag *tileTicks = (ListTag *) tag->getList(L"TileTicks"); - if (tag->contains(L"TileTicks")) + if (tileTicks != NULL) { - ListTag *tileTicks = (ListTag *) tag->getList(L"TileTicks"); - - if (tileTicks != NULL) + for (int i = 0; i < tileTicks->size(); i++) { - for (int i = 0; i < tileTicks->size(); i++) - { - CompoundTag *teTag = tileTicks->get(i); + CompoundTag *teTag = tileTicks->get(i); - level->forceAddTileTick(teTag->getInt(L"x"), teTag->getInt(L"y"), teTag->getInt(L"z"), teTag->getInt(L"i"), teTag->getInt(L"t")); - } + level->forceAddTileTick(teTag->getInt(L"x"), teTag->getInt(L"y"), teTag->getInt(L"z"), teTag->getInt(L"i"), teTag->getInt(L"t"), teTag->getInt(L"p")); } } - - delete tag; + PIXEndNamedEvent(); } + delete tag; + + PIXEndNamedEvent(); + return levelChunk; } diff --git a/Minecraft.World/RandomLevelSource.cpp b/Minecraft.World/RandomLevelSource.cpp index 51954be9..9c24e4b3 100644 --- a/Minecraft.World/RandomLevelSource.cpp +++ b/Minecraft.World/RandomLevelSource.cpp @@ -778,7 +778,7 @@ void RandomLevelSource::postProcess(ChunkSource *parent, int xt, int zt) mineShaftFeature->postProcess(level, pprandom, xt, zt); hasVillage = villageFeature->postProcess(level, pprandom, xt, zt); strongholdFeature->postProcess(level, pprandom, xt, zt); - scatteredFeature->postProcess(level, pprandom, xt, zt); + scatteredFeature->postProcess(level, random, xt, zt); } PIXEndNamedEvent(); diff --git a/Minecraft.World/RegionFile.cpp b/Minecraft.World/RegionFile.cpp index de920fa9..305337a8 100644 --- a/Minecraft.World/RegionFile.cpp +++ b/Minecraft.World/RegionFile.cpp @@ -38,12 +38,7 @@ RegionFile::RegionFile(ConsoleSaveFile *saveFile, File *path) } */ - wstring saveName = fileName->getPath(); - for (size_t i = 0; i < saveName.size(); i++) - { - if (saveName[i] == L'\\') saveName[i] = L'/'; - } - fileEntry = m_saveFile->createFile( ConsoleSavePath(saveName) ); + fileEntry = m_saveFile->createFile( fileName->getName() ); m_saveFile->setFilePointer( fileEntry, 0, NULL, FILE_END ); if ( fileEntry->getFileSize() < SECTOR_BYTES) diff --git a/Minecraft.World/RegionFileCache.cpp b/Minecraft.World/RegionFileCache.cpp index 3b84f773..6b88f4e0 100644 --- a/Minecraft.World/RegionFileCache.cpp +++ b/Minecraft.World/RegionFileCache.cpp @@ -17,7 +17,7 @@ bool RegionFileCache::useSplitSaves(ESavePlatform platform) }; } -RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) // 4J - synchronized restored +RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) // 4J - TODO was synchronized { // 4J Jev - changed back to use of the File class. //char file[MAX_PATH_SIZE]; @@ -26,7 +26,6 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst //File regionDir(basePath, L"region"); //File file(regionDir, wstring(L"r.") + _toString(chunkX>>5) + L"." + _toString(chunkZ>>5) + L".mcr" ); - EnterCriticalSection(&m_cs); MemSect(31); File file; if(useSplitSaves(saveFile->getSavePlatform())) @@ -47,7 +46,6 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst // 4J Jev, put back in. if (ref != NULL) { - LeaveCriticalSection(&m_cs); return ref; } @@ -65,14 +63,12 @@ RegionFile *RegionFileCache::_getRegionFile(ConsoleSaveFile *saveFile, const wst RegionFile *reg = new RegionFile(saveFile, &file); cache[file] = reg; // 4J - this was originally a softReferenc - LeaveCriticalSection(&m_cs); return reg; } void RegionFileCache::_clear() // 4J - TODO was synchronized { - EnterCriticalSection(&m_cs); AUTO_VAR(itEnd, cache.end()); for( AUTO_VAR(it, cache.begin()); it != itEnd; it++ ) { @@ -89,7 +85,6 @@ void RegionFileCache::_clear() // 4J - TODO was synchronized // } } cache.clear(); - LeaveCriticalSection(&m_cs); } int RegionFileCache::_getSizeDelta(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ) @@ -125,3 +120,9 @@ DataOutputStream *RegionFileCache::_getChunkDataOutputStream(ConsoleSaveFile *sa return r->getChunkDataOutputStream(chunkX & 31, chunkZ & 31); } } + + +RegionFileCache::~RegionFileCache() +{ + _clear(); +} diff --git a/Minecraft.World/RegionFileCache.h b/Minecraft.World/RegionFileCache.h index 58af1f03..822e49c9 100644 --- a/Minecraft.World/RegionFileCache.h +++ b/Minecraft.World/RegionFileCache.h @@ -10,14 +10,13 @@ private: static const int MAX_CACHE_SIZE = 256; unordered_map cache; - CRITICAL_SECTION m_cs; static RegionFileCache s_defaultCache; public: // Made public and non-static so we can have a cache for input and output files - RegionFileCache() { InitializeCriticalSectionAndSpinCount(&m_cs, 4000); } - ~RegionFileCache() { DeleteCriticalSection(&m_cs); _clear(); } + RegionFileCache() {} + ~RegionFileCache(); RegionFile *_getRegionFile(ConsoleSaveFile *saveFile, const wstring &prefix, int chunkX, int chunkZ); // 4J - TODO was synchronized void _clear(); // 4J - TODO was synchronized diff --git a/Minecraft.World/SparseDataStorage.cpp b/Minecraft.World/SparseDataStorage.cpp index 0e460214..dc32a431 100644 --- a/Minecraft.World/SparseDataStorage.cpp +++ b/Minecraft.World/SparseDataStorage.cpp @@ -602,10 +602,9 @@ bool SparseDataStorage::isCompressed() void SparseDataStorage::write(DataOutputStream *dos) { - __int64 snapshot = dataAndCount; - int count = ( snapshot >> 48 ) & 0xffff; + int count = ( dataAndCount >> 48 ) & 0xffff; dos->writeInt(count); - unsigned char *dataPointer = (unsigned char *)(snapshot & 0x0000ffffffffffff); + unsigned char *dataPointer = (unsigned char *)(dataAndCount & 0x0000ffffffffffff); byteArray wrapper(dataPointer, count * 128 + 128); dos->write(wrapper); } diff --git a/Minecraft.World/SparseLightStorage.cpp b/Minecraft.World/SparseLightStorage.cpp index 7257f29d..8b848520 100644 --- a/Minecraft.World/SparseLightStorage.cpp +++ b/Minecraft.World/SparseLightStorage.cpp @@ -619,10 +619,9 @@ bool SparseLightStorage::isCompressed() void SparseLightStorage::write(DataOutputStream *dos) { - __int64 snapshot = dataAndCount; - int count = ( snapshot >> 48 ) & 0xffff; + int count = ( dataAndCount >> 48 ) & 0xffff; dos->writeInt(count); - unsigned char *dataPointer = (unsigned char *)(snapshot & 0x0000ffffffffffff); + unsigned char *dataPointer = (unsigned char *)(dataAndCount & 0x0000ffffffffffff); byteArray wrapper(dataPointer, count * 128 + 128); dos->write(wrapper); } diff --git a/Minecraft.World/StrongholdPieces.cpp b/Minecraft.World/StrongholdPieces.cpp index bdd18c04..40bce30f 100644 --- a/Minecraft.World/StrongholdPieces.cpp +++ b/Minecraft.World/StrongholdPieces.cpp @@ -222,7 +222,7 @@ StructurePiece *StrongholdPieces::generateAndAddPiece(StartPiece *startPiece, li if(piece->pieceClass != EPieceClass_PortalRoom) continue; #ifndef _CONTENT_PACKAGE - app.DebugPrintf("Portal room forcing attempt\n"); + printf("Portal room forcing attempt\n"); #endif StrongholdPiece *strongholdPiece = PortalRoom::createPiece(pieces, random, footX, footY, footZ, direction, depth); if (strongholdPiece != NULL) @@ -235,7 +235,7 @@ StructurePiece *StrongholdPieces::generateAndAddPiece(StartPiece *startPiece, li currentPieces.remove(piece); } #ifndef _CONTENT_PACKAGE - app.DebugPrintf("Success\n"); + printf("Success\n"); #endif return strongholdPiece; } diff --git a/Minecraft.World/StructureFeature.cpp b/Minecraft.World/StructureFeature.cpp index ba10ceec..ab4e37db 100644 --- a/Minecraft.World/StructureFeature.cpp +++ b/Minecraft.World/StructureFeature.cpp @@ -9,7 +9,6 @@ StructureFeature::StructureFeature() { - InitializeCriticalSectionAndSpinCount(&m_csCachedStructures, 4000); #ifdef ENABLE_STRUCTURE_SAVING savedData = nullptr; #endif @@ -17,13 +16,10 @@ StructureFeature::StructureFeature() StructureFeature::~StructureFeature() { - EnterCriticalSection(&m_csCachedStructures); for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ ) { delete it->second; } - LeaveCriticalSection(&m_csCachedStructures); - DeleteCriticalSection(&m_csCachedStructures); } void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOffs, byteArray blocks) @@ -32,16 +28,12 @@ void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOf // the chunk being generated, but not all chunks are the sources of // structures - EnterCriticalSection(&m_csCachedStructures); - restoreSavedData(level); if (cachedStructures.find(ChunkPos::hashCode(x, z)) != cachedStructures.end()) { - LeaveCriticalSection(&m_csCachedStructures); return; } - LeaveCriticalSection(&m_csCachedStructures); // clear random key random->nextInt(); @@ -49,9 +41,7 @@ void StructureFeature::addFeature(Level *level, int x, int z, int xOffs, int zOf if (isFeatureChunk(x, z,level->getLevelData()->getGenerator() == LevelType::lvl_flat)) { StructureStart *start = createStructureStart(x, z); - EnterCriticalSection(&m_csCachedStructures); cachedStructures[ChunkPos::hashCode(x, z)] = start; - LeaveCriticalSection(&m_csCachedStructures); saveFeature(x, z, start); } } @@ -68,7 +58,6 @@ bool StructureFeature::postProcess(Level *level, Random *random, int chunkX, int int cz = (chunkZ << 4); // + 8; bool intersection = false; - EnterCriticalSection(&m_csCachedStructures); for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ ) { StructureStart *structureStart = it->second; @@ -87,14 +76,12 @@ bool StructureFeature::postProcess(Level *level, Random *random, int chunkX, int } } } - LeaveCriticalSection(&m_csCachedStructures); return intersection; } bool StructureFeature::isIntersection(int cellX, int cellZ) { - EnterCriticalSection(&m_csCachedStructures); restoreSavedData(level); for( AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); it++ ) @@ -110,14 +97,12 @@ bool StructureFeature::isIntersection(int cellX, int cellZ) StructurePiece *next = *it2++; if (next->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ)) { - LeaveCriticalSection(&m_csCachedStructures); return true; } } } } } - LeaveCriticalSection(&m_csCachedStructures); return false; } @@ -129,7 +114,6 @@ bool StructureFeature::isInsideFeature(int cellX, int cellY, int cellZ) StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ) { - EnterCriticalSection(&m_csCachedStructures); //for (StructureStart structureStart : cachedStructures.values()) for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it) { @@ -154,14 +138,12 @@ StructureStart *StructureFeature::getStructureAt(int cellX, int cellY, int cellZ StructurePiece* piece = *it2; if ( piece->getBoundingBox()->isInside(cellX, cellY, cellZ) ) { - LeaveCriticalSection(&m_csCachedStructures); return pStructureStart; } } } } } - LeaveCriticalSection(&m_csCachedStructures); return NULL; } @@ -169,17 +151,14 @@ bool StructureFeature::isInsideBoundingFeature(int cellX, int cellY, int cellZ) { restoreSavedData(level); - EnterCriticalSection(&m_csCachedStructures); for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it) { StructureStart *structureStart = it->second; if (structureStart->isValid()) { - LeaveCriticalSection(&m_csCachedStructures); return (structureStart->getBoundingBox()->intersects(cellX, cellZ, cellX, cellZ)); } } - LeaveCriticalSection(&m_csCachedStructures); return false; } @@ -203,7 +182,6 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i double minDistance = DBL_MAX; TilePos *selected = NULL; - EnterCriticalSection(&m_csCachedStructures); for(AUTO_VAR(it, cachedStructures.begin()); it != cachedStructures.end(); ++it) { StructureStart *pStructureStart = it->second; @@ -227,7 +205,6 @@ TilePos *StructureFeature::getNearestGeneratedFeature(Level *level, int cellX, i } } } - LeaveCriticalSection(&m_csCachedStructures); if (selected != NULL) { return selected; diff --git a/Minecraft.World/StructureFeature.h b/Minecraft.World/StructureFeature.h index 16e246cb..5159343a 100644 --- a/Minecraft.World/StructureFeature.h +++ b/Minecraft.World/StructureFeature.h @@ -27,7 +27,6 @@ private: protected: unordered_map<__int64, StructureStart *> cachedStructures; - CRITICAL_SECTION m_csCachedStructures; public: StructureFeature();