diff --git a/targets/4J.Input/4J_Input.cpp b/targets/4J.Input/4J_Input.cpp index 037554362..e0e0beece 100644 --- a/targets/4J.Input/4J_Input.cpp +++ b/targets/4J.Input/4J_Input.cpp @@ -660,6 +660,8 @@ void C_4JInput::CancelQueuedVerifyStrings(int (*)(void*, void C_4JInput::CancelAllVerifyInProgress() {} // Primary pad (moved from Profile) -namespace { int s_inputPrimaryPad = 0; } +namespace { +int s_inputPrimaryPad = 0; +} int C_4JInput::GetPrimaryPad() { return s_inputPrimaryPad; } void C_4JInput::SetPrimaryPad(int iPad) { s_inputPrimaryPad = iPad; } diff --git a/targets/4J.Input/4J_Input.h b/targets/4J.Input/4J_Input.h index a592291ad..a93bb8d6e 100644 --- a/targets/4J.Input/4J_Input.h +++ b/targets/4J.Input/4J_Input.h @@ -51,7 +51,6 @@ class C_4JInput : public IPlatformInput { public: - void Initialise(int iInputStateC, unsigned char ucMapC, unsigned char ucActionC, unsigned char ucMenuActionC); void Tick(void); diff --git a/targets/4J.Profile/4J_Profile.cpp b/targets/4J.Profile/4J_Profile.cpp index 3b0aaf846..6e391dd0a 100644 --- a/targets/4J.Profile/4J_Profile.cpp +++ b/targets/4J.Profile/4J_Profile.cpp @@ -158,8 +158,9 @@ std::wstring C_4JProfile::GetDisplayName(int iPad) { return s_displayNames[p]; } -int C_4JProfile::SetDefaultOptionsCallback( - int (*Func)(void*, PROFILESETTINGS*, const int iPad), void* lpParam) { +int C_4JProfile::SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*, + const int iPad), + void* lpParam) { s_defaultOptionsCallback = Func; s_defaultOptionsCallbackParam = lpParam; return 0; diff --git a/targets/4J.Profile/4J_Profile.h b/targets/4J.Profile/4J_Profile.h index 5b483078b..a0e8c2663 100644 --- a/targets/4J.Profile/4J_Profile.h +++ b/targets/4J.Profile/4J_Profile.h @@ -71,17 +71,25 @@ public: void Tick() {} unsigned int RequestSignInUI(bool, bool, bool, bool, bool, - int (*)(void*, const bool, const int), - void*, int = XUSER_INDEX_ANY) { return 0; } + int (*)(void*, const bool, const int), void*, + int = XUSER_INDEX_ANY) { + return 0; + } unsigned int DisplayOfflineProfile(int (*)(void*, const bool, const int), - void*, int = XUSER_INDEX_ANY) { return 0; } - unsigned int RequestConvertOfflineToGuestUI( - int (*)(void*, const bool, const int), void*, - int = XUSER_INDEX_ANY) { return 0; } + void*, int = XUSER_INDEX_ANY) { + return 0; + } + unsigned int RequestConvertOfflineToGuestUI(int (*)(void*, const bool, + const int), + void*, int = XUSER_INDEX_ANY) { + return 0; + } void SetPrimaryPlayerChanged(bool) {} void ShowProfileCard(int, PlayerUID) {} bool GetProfileAvatar(int, int (*)(void*, std::uint8_t*, unsigned int), - void*) { return false; } + void*) { + return false; + } void CancelProfileAvatarRequest() {} void SetSignInChangeCallback(void (*)(void*, bool, unsigned int), void*) {} void SetNotificationsCallback(void (*)(void*, std::uint32_t, unsigned int), @@ -93,13 +101,15 @@ public: void SetProfileReadErrorCallback(void (*)(void*), void*) {} int SetOldProfileVersionCallback(int (*)(void*, unsigned char*, const unsigned short, const int), - void*) { return 0; } + void*) { + return 0; + } void WriteToProfile(int, bool = false, bool = false) {} void ForceQueuedProfileWrites(int = XUSER_INDEX_ANY) {} void ResetProfileProcessState() {} void RegisterAward(int, int, EAwardType, bool = false, - CXuiStringTable* = nullptr, int = -1, int = -1, - int = -1, char* = nullptr, unsigned int = 0L) {} + CXuiStringTable* = nullptr, int = -1, int = -1, int = -1, + char* = nullptr, unsigned int = 0L) {} int GetAwardId(int) { return 0; } EAwardType GetAwardType(int) { return eAwardType_Achievement; } bool CanBeAwarded(int, int) { return false; } diff --git a/targets/Minecraft.Client/Common/Consoles_App.cpp b/targets/Minecraft.Client/Common/Consoles_App.cpp index 4bad22c62..b2edfe4b6 100644 --- a/targets/Minecraft.Client/Common/Consoles_App.cpp +++ b/targets/Minecraft.Client/Common/Consoles_App.cpp @@ -66,7 +66,6 @@ #include #include - // CMinecraftApp app; unsigned int CMinecraftApp::m_uiLastSignInData = 0; @@ -147,7 +146,7 @@ CMinecraftApp::CMinecraftApp() { m_xuidNotch = INVALID_XUID; - memset(&m_InviteData, 0, sizeof(JoinFromInviteData)); + memset(&m_InviteData, 0, sizeof(JoinFromInviteData)); // m_bRead_TMS_XUIDS_XML=false; // m_bRead_TMS_DLCINFO_XML=false; @@ -164,7 +163,7 @@ CMinecraftApp::CMinecraftApp() { m_iTotalDLCInstalled = 0; mfTrialPausedTime = 0.0f; m_uiAutosaveTimer = 0; - memset(m_pszUniqueMapName, 0, 14); + memset(m_pszUniqueMapName, 0, 14); m_bNewDLCAvailable = false; m_bSeenNewDLCTip = false; @@ -177,7 +176,7 @@ CMinecraftApp::CMinecraftApp() { m_GameNewHellScale = 0; #endif - memset(m_playerColours, 0, MINECRAFT_NET_MAX_PLAYERS); + memset(m_playerColours, 0, MINECRAFT_NET_MAX_PLAYERS); m_iDLCOfferC = 0; m_bAllDLCContentRetrieved = true; @@ -2212,8 +2211,10 @@ void CMinecraftApp::HandleXuiActions(void) { // CSocialManager::Instance() // ->AreAllUsersAllowedToPostImages()) { // // disable character name tags for the shot - // // m_bwasHidingGui = pMinecraft->options->hideGui; - // // // 4J Stu - Removed 1.8.2 bug fix (TU6) as don't + // // m_bwasHidingGui = + // pMinecraft->options->hideGui; + // // // 4J Stu - Removed 1.8.2 bug fix (TU6) as + // don't // // need this // pMinecraft->options->hideGui = true; @@ -2577,8 +2578,7 @@ void CMinecraftApp::HandleXuiActions(void) { return; } // flag to capture the save thumbnail - SetAction(i, eAppAction_ExitWorldCapturedThumbnail, - param); + SetAction(i, eAppAction_ExitWorldCapturedThumbnail, param); // Change the presence info // Are we offline or online, and how many players are there @@ -2878,7 +2878,8 @@ void CMinecraftApp::HandleXuiActions(void) { bool gameStarted = false; for (int j = 0; j < pMinecraft->levels.size(); j++) { - if (pMinecraft->levels.data()[j] != nullptr) { + if (pMinecraft->levels.data()[j] != + nullptr) { gameStarted = true; break; } @@ -3078,9 +3079,8 @@ void CMinecraftApp::HandleXuiActions(void) { uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[1] = IDS_CONFIRM_OK; ui.RequestAlertMessage( - IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, - uiIDA, 2, i, - &CMinecraftApp::ExitAndJoinFromInvite, this); + IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA, + 2, i, &CMinecraftApp::ExitAndJoinFromInvite, this); } } break; case eAppAction_ExitAndJoinFromInviteConfirmed: { @@ -3381,7 +3381,6 @@ void CMinecraftApp::HandleXuiActions(void) { // can't ban the level at that point if (g_NetworkManager.IsInGameplay() && !g_NetworkManager.IsLeavingGame()) { - // primary player would exit the world, secondary would // exit the player if (ProfileManager.GetPrimaryPad() == i) { @@ -3636,7 +3635,8 @@ void CMinecraftApp::loadStringTable() { } std::wstring localisationFile = L"languages.loc"; if (m_mediaArchive->hasFile(localisationFile)) { - std::vector locFile = m_mediaArchive->getFile(localisationFile); + std::vector locFile = + m_mediaArchive->getFile(localisationFile); m_stringTable = new StringTable(locFile.data(), locFile.size()); } else { m_stringTable = nullptr; @@ -4369,8 +4369,7 @@ void CMinecraftApp::UpdateTime() { m_Time.qwAppTime += qwDeltaTime; m_Time.qwTime = qwNewTime; - m_Time.fElapsedTime = - m_Time.fSecsPerTick * static_cast(qwDeltaTime); + m_Time.fElapsedTime = m_Time.fSecsPerTick * static_cast(qwDeltaTime); m_Time.fAppTime = m_Time.fSecsPerTick * static_cast(m_Time.qwAppTime); } @@ -4816,7 +4815,7 @@ int CMinecraftApp::TipsSortFunction(const void* a, const void* b) { void CMinecraftApp::InitialiseTips() { // We'll randomise the tips at start up based on their priority - memset(m_TipIDA, 0, sizeof(m_TipIDA)); + memset(m_TipIDA, 0, sizeof(m_TipIDA)); // Make the first tip tell you that you can play splitscreen in HD modes if // you are in SD @@ -4873,8 +4872,7 @@ void CMinecraftApp::InitialiseTips() { int CMinecraftApp::GetNextTip() { static bool bShowSkinDLCTip = true; - if (app.GetNewDLCAvailable() && - app.DisplayNewDLCTip()) { + if (app.GetNewDLCAvailable() && app.DisplayNewDLCTip()) { return IDS_TIPS_GAMETIP_NEWDLC; } else { if (bShowSkinDLCTip) { @@ -5261,7 +5259,7 @@ int32_t CMinecraftApp::RegisterMojangData(wchar_t* pXuidName, PlayerUID xuid, if (eTempXuid != eXUID_Undefined) { pMojangData = new MOJANG_DATA; - memset(pMojangData, 0, sizeof(MOJANG_DATA)); + memset(pMojangData, 0, sizeof(MOJANG_DATA)); pMojangData->eXuid = eTempXuid; wcsncpy(pMojangData->wchSkin, pSkin, MAX_CAPENAME_SIZE); @@ -5313,7 +5311,7 @@ int32_t CMinecraftApp::RegisterDLCData(wchar_t* pType, wchar_t* pBannerName, wchar_t* pDataFile) { int32_t hr = 0; DLC_INFO* pDLCData = new DLC_INFO; - memset(pDLCData, 0, sizeof(DLC_INFO)); + memset(pDLCData, 0, sizeof(DLC_INFO)); pDLCData->ullOfferID_Full = ullOfferID_Full; pDLCData->ullOfferID_Trial = ullOfferID_Trial; pDLCData->eDLCType = e_DLC_NotDefined; @@ -5375,7 +5373,7 @@ int32_t CMinecraftApp::RegisterDLCData(char* pchDLCName, char chDLCType[3]; int32_t hr = 0; DLC_INFO* pDLCData = new DLC_INFO; - memset(pDLCData, 0, sizeof(DLC_INFO)); + memset(pDLCData, 0, sizeof(DLC_INFO)); chDLCType[0] = pchDLCName[0]; chDLCType[1] = pchDLCName[1]; @@ -5702,7 +5700,6 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid, if (pBannedListData != nullptr) { if (IsEqualXUID(pBannedListData->xuid, xuid) && (strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) { - // match found, so remove this entry it = m_vBannedListA[iPad]->erase(it); } else { @@ -6203,7 +6200,7 @@ void CMinecraftApp::GetImageTextData(std::uint8_t* imageData, // check that it's the 4J text unsigned char* pszKeyword = &ucPtr[uiCount]; while (pszKeyword < ucPtr + uiCount + uiChunkLen) { - memset(szKeyword, 0, 80); + memset(szKeyword, 0, 80); unsigned int uiKeywordC = 0; while (*pszKeyword != 0) { szKeyword[uiKeywordC++] = *pszKeyword; @@ -6225,7 +6222,7 @@ void CMinecraftApp::GetImageTextData(std::uint8_t* imageData, unsigned int uiValueC = 0; unsigned char pszHostOptions[9]; // Hex representation of // unsigned int - memset(&pszHostOptions, 0, 9); + memset(&pszHostOptions, 0, 9); while (*pszKeyword != 0 && (pszKeyword < ucPtr + uiCount + uiChunkLen) && uiValueC < 8) { @@ -6242,7 +6239,7 @@ void CMinecraftApp::GetImageTextData(std::uint8_t* imageData, unsigned int uiValueC = 0; unsigned char pszTexturePack[9]; // Hex representation of // unsigned int - memset(&pszTexturePack, 0, 9); + memset(&pszTexturePack, 0, 9); while (*pszKeyword != 0 && (pszKeyword < ucPtr + uiCount + uiChunkLen) && uiValueC < 8) { @@ -6653,7 +6650,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType, // app.DebugPrintf("Adding a request to the TMSPP // download queue - %ls\n",pDLC->wchBanner); TMSPPRequest* pTMSPPreq = new TMSPPRequest; - memset(pTMSPPreq, 0, sizeof(TMSPPRequest)); + memset(pTMSPPreq, 0, sizeof(TMSPPRequest)); pTMSPPreq->CallbackFunc = &CMinecraftApp::TMSPPFileReturned; @@ -7115,7 +7112,8 @@ bool CMinecraftApp::hasArchiveFile(const std::wstring& filename) { return m_mediaArchive->hasFile(filename); } -std::vector CMinecraftApp::getArchiveFile(const std::wstring& filename) { +std::vector CMinecraftApp::getArchiveFile( + const std::wstring& filename) { TexturePack* tPack = nullptr; Minecraft* pMinecraft = Minecraft::GetInstance(); if (pMinecraft && pMinecraft->skins) diff --git a/targets/Minecraft.Client/Common/Consoles_App.h b/targets/Minecraft.Client/Common/Consoles_App.h index 30c7b8de1..cdda8ba22 100644 --- a/targets/Minecraft.Client/Common/Consoles_App.h +++ b/targets/Minecraft.Client/Common/Consoles_App.h @@ -491,8 +491,8 @@ public: bool m_bChangingSessionType; bool m_bReallyChangingSessionType; - // trial, and trying to unlock full - // version on an upsell + // trial, and trying to unlock full + // version on an upsell void loadMediaArchive(); void loadStringTable(); diff --git a/targets/Minecraft.Client/Common/src/Audio/SoundEngine.cpp b/targets/Minecraft.Client/Common/src/Audio/SoundEngine.cpp index ab6992fa3..194a5e00c 100644 --- a/targets/Minecraft.Client/Common/src/Audio/SoundEngine.cpp +++ b/targets/Minecraft.Client/Common/src/Audio/SoundEngine.cpp @@ -184,8 +184,9 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume, if (szId[i] == '.') szId[i] = '/'; std::string base = PathHelper::GetExecutableDirA() + "/"; - const char* roots[] = {"Sound/Minecraft/", "Minecraft.Client/Common/Sound/Minecraft/", - "Minecraft.Client/Common/res/TitleUpdate/res/Sound/Minecraft/"}; + const char* roots[] = { + "Sound/Minecraft/", "Minecraft.Client/Common/Sound/Minecraft/", + "Minecraft.Client/Common/res/TitleUpdate/res/Sound/Minecraft/"}; char finalPath[512] = {0}; bool found = false; @@ -457,7 +458,8 @@ void SoundEngine::playMusicTick() { bool found = false; m_szStreamName[0] = '\0'; - const char* roots[] = {"Minecraft.Client/Common/music/", "music/", "./"}; + const char* roots[] = {"Minecraft.Client/Common/music/", + "music/", "./"}; for (const char* r : roots) { for (const char* e : {".ogg", ".mp3", ".wav"}) { @@ -1135,8 +1137,10 @@ void SoundEngine::tick(std::shared_ptr* players, float a) { float yRot = players[i]->yRotO + (players[i]->yRot - players[i]->yRotO) * a; - float yCos = (float)cos(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); - float ySin = (float)sin(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float yCos = + (float)cos(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); + float ySin = + (float)sin(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); // store the listener positions for splitscreen m_ListenerA[i].vPosition.x = x; diff --git a/targets/Minecraft.Client/Common/src/Colours/ColourTable.cpp b/targets/Minecraft.Client/Common/src/Colours/ColourTable.cpp index 6fbc17ed9..7a9f163af 100644 --- a/targets/Minecraft.Client/Common/src/Colours/ColourTable.cpp +++ b/targets/Minecraft.Client/Common/src/Colours/ColourTable.cpp @@ -347,7 +347,7 @@ ColourTable::ColourTable(ColourTable* defaultColours, std::uint8_t* pbData, std::uint32_t dataLength) { // 4J Stu - Default the colours that of the table passed in memcpy((void*)m_colourValues, (void*)defaultColours->m_colourValues, - sizeof(int) * eMinecraftColour_COUNT); + sizeof(int) * eMinecraftColour_COUNT); loadColoursFromData(pbData, dataLength); } void ColourTable::loadColoursFromData(std::uint8_t* pbData, diff --git a/targets/Minecraft.Client/Common/src/DLC/DLCSkinFile.cpp b/targets/Minecraft.Client/Common/src/DLC/DLCSkinFile.cpp index a11cfd537..31cd763d3 100644 --- a/targets/Minecraft.Client/Common/src/DLC/DLCSkinFile.cpp +++ b/targets/Minecraft.Client/Common/src/DLC/DLCSkinFile.cpp @@ -109,12 +109,11 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, case DLCManager::e_DLCParamType_Box: { wchar_t wchBodyPart[10]; SKIN_BOX* pSkinBox = new SKIN_BOX; - memset(pSkinBox, 0, sizeof(SKIN_BOX)); + memset(pSkinBox, 0, sizeof(SKIN_BOX)); swscanf(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10, - &pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, - &pSkinBox->fW, &pSkinBox->fH, &pSkinBox->fD, - &pSkinBox->fU, &pSkinBox->fV); + &pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW, + &pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV); if (wcscmp(wchBodyPart, L"HEAD") == 0) { pSkinBox->ePart = eBodyPart_Head; @@ -135,7 +134,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type, } break; case DLCManager::e_DLCParamType_Anim: { swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask, - sizeof(unsigned int)); + sizeof(unsigned int)); uint32_t skinId = app.getSkinIdFromPath(m_path); app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask); break; diff --git a/targets/Minecraft.Client/Common/src/GameRules/GameRuleManager.cpp b/targets/Minecraft.Client/Common/src/GameRules/GameRuleManager.cpp index e8b86842b..10b4c0c3b 100644 --- a/targets/Minecraft.Client/Common/src/GameRules/GameRuleManager.cpp +++ b/targets/Minecraft.Client/Common/src/GameRules/GameRuleManager.cpp @@ -199,7 +199,6 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn, dis.close(); bais.close(); - ByteArrayInputStream bais2(content); DataInputStream dis2(&bais2); @@ -228,7 +227,6 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn, delete lgo; } - // Close and return. dis2.close(); bais2.close(); @@ -286,8 +284,8 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* dSize) { // Write string table. uint8_t* stbaPtr = nullptr; unsigned int stbaSize = 0; - m_currentGameRuleDefinitions->getStringTable()->getData( - &stbaPtr, &stbaSize); + m_currentGameRuleDefinitions->getStringTable()->getData(&stbaPtr, + &stbaSize); std::vector stba(stbaPtr, stbaPtr + stbaSize); compr_dos.writeInt(stba.size()); compr_dos.write(stba); @@ -313,7 +311,6 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* dSize) { dos.writeInt(compr_baos.buf.size()); dos.write(compr_ba); - compr_dos.close(); compr_baos.close(); // -- END COMPRESSED -- // @@ -416,7 +413,8 @@ bool GameRuleManager::readRuleFile( std::vector compressedBuffer(compressedSize); dis.read(compressedBuffer); - std::vector decompressedBuffer = std::vector(uncompressedSize); + std::vector decompressedBuffer = + std::vector(uncompressedSize); unsigned int decompressedSize = uncompressedSize; switch (compressionType) { @@ -467,7 +465,6 @@ bool GameRuleManager::readRuleFile( */ }; - contentBais = new ByteArrayInputStream(decompressedBuffer); contentDis = new DataInputStream(contentBais); } diff --git a/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ApplySchematicRuleDefinition.cpp b/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ApplySchematicRuleDefinition.cpp index 310ed8424..14d6682e8 100644 --- a/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ApplySchematicRuleDefinition.cpp +++ b/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ApplySchematicRuleDefinition.cpp @@ -166,7 +166,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox, if (m_completed) return; if (chunk->level->dimension->id != m_dimension) return; - if (m_schematic == nullptr) + if (m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); if (!m_locationBox.has_value()) updateLocationBox(); @@ -178,14 +178,12 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox, app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n", m_schematicName.c_str(), chunk->x, chunk->z); #endif - m_totalBlocksChanged += m_schematic->applyBlocksAndData( + m_totalBlocksChanged += m_schematic->applyBlocksAndData( chunk, chunkBox, &*m_locationBox, m_rotation); - // Add the tileEntities - m_schematic->applyTileEntities(chunk, chunkBox, &*m_locationBox, + m_schematic->applyTileEntities(chunk, chunkBox, &*m_locationBox, m_rotation); - // TODO This does not take into account things that go outside the // bounds of the world @@ -199,7 +197,6 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox, // m_schematic = nullptr; } } - } void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox, @@ -207,7 +204,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox, if (m_completed) return; if (chunk->level->dimension->id != m_dimension) return; - if (m_schematic == nullptr) + if (m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); if (!m_locationBox.has_value()) updateLocationBox(); @@ -219,9 +216,8 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox, app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n", m_schematicName.c_str(), chunk->x, chunk->z); #endif - m_totalBlocksChangedLighting += m_schematic->applyLighting( + m_totalBlocksChangedLighting += m_schematic->applyLighting( chunk, chunkBox, &*m_locationBox, m_rotation); - // TODO This does not take into account things that go outside the // bounds of the world @@ -235,7 +231,6 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox, // m_schematic = nullptr; } } - } bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0, diff --git a/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ConsoleSchematicFile.cpp b/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ConsoleSchematicFile.cpp index 645fa3364..741f1f476 100644 --- a/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ConsoleSchematicFile.cpp +++ b/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ConsoleSchematicFile.cpp @@ -62,7 +62,6 @@ void ConsoleSchematicFile::save(DataOutputStream* dos) { dos->write(ba); save_tags(dos); - } } @@ -126,7 +125,6 @@ void ConsoleSchematicFile::load(DataInputStream* dis) { Compression::getCompression()->SetDecompressionType( APPROPRIATE_COMPRESSION_TYPE); }; - } // READ TAGS // @@ -228,12 +226,13 @@ int64_t ConsoleSchematicFile::applyBlocksAndData(LevelChunk* chunk, int rowBlockCount = getYSize() * getZSize(); int totalBlockCount = getXSize() * rowBlockCount; - std::vector blockData = std::vector(Level::CHUNK_TILE_COUNT); - chunk->getBlockData(blockData); - - std::vector dataData = std::vector(Level::HALF_CHUNK_TILE_COUNT); - chunk->getDataData(dataData); - + std::vector blockData = + std::vector(Level::CHUNK_TILE_COUNT); + chunk->getBlockData(blockData); + + std::vector dataData = + std::vector(Level::HALF_CHUNK_TILE_COUNT); + chunk->getDataData(dataData); // Ignore light data int blockLightP = -1; @@ -305,11 +304,10 @@ int64_t ConsoleSchematicFile::applyBlocksAndData(LevelChunk* chunk, // } //} - chunk->setBlockData(blockData); - + chunk->setBlockData(blockData); + chunk->recalcHeightmapOnly(); - chunk->setDataData(dataData); - + chunk->setDataData(dataData); // A basic pass through to roughly do the lighting. At this point of // post-processing, we don't have all the neighbouring chunks loaded in, so @@ -637,8 +635,8 @@ void ConsoleSchematicFile::generateSchematicFile( // Write zSize if (dos != nullptr) dos->writeInt(zSize); - // std::vector rawBuffer = level->getBlocksAndData(xStart, yStart, zStart, - // xSize, ySize, zSize, false); + // std::vector rawBuffer = level->getBlocksAndData(xStart, yStart, + // zStart, xSize, ySize, zSize, false); int xRowSize = ySize * zSize; int blockCount = xSize * xRowSize; std::vector result(blockCount * 3 / 2); @@ -701,7 +699,8 @@ void ConsoleSchematicFile::generateSchematicFile( break; }; - std::vector buffer = std::vector(ucTemp, ucTemp + inputSize); + std::vector buffer = + std::vector(ucTemp, ucTemp + inputSize); delete[] ucTemp; if (dos != nullptr) dos->writeInt(inputSize); @@ -794,11 +793,11 @@ void ConsoleSchematicFile::generateSchematicFile( if (dos != nullptr) NbtIo::write(&tag, dos); } -void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector* data, - int x0, int y0, int z0, int x1, - int y1, int z1, int& blocksP, - int& dataP, int& blockLightP, - int& skyLightP) { +void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, + std::vector* data, int x0, + int y0, int z0, int x1, int y1, + int z1, int& blocksP, int& dataP, + int& blockLightP, int& skyLightP) { // 4J Stu - Needs updated to work with higher worlds, should still work with // non-optimised version below // int xs = x1 - x0; @@ -806,22 +805,23 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector blockData = std::vector(data->data + blocksP, + // std::vector blockData = std::vector(data->data + + // blocksP, // Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData); // blocksP += blockData.size(); - // std::vector dataData = std::vector(data->data + dataP, 16384); - // chunk->getBlockLightData(dataData); - // dataP += dataData.size(); + // std::vector dataData = std::vector(data->data + dataP, + // 16384); chunk->getBlockLightData(dataData); dataP += + // dataData.size(); - // std::vector blockLightData = std::vector(data->data + blockLightP, 16384); - // chunk->getBlockLightData(blockLightData); - // blockLightP += blockLightData.size(); + // std::vector blockLightData = std::vector(data->data + + // blockLightP, 16384); chunk->getBlockLightData(blockLightData); + // blockLightP + //+= blockLightData.size(); - // std::vector skyLightData = std::vector(data->data + skyLightP, 16384); - // chunk->getSkyLightData(skyLightData); - // skyLightP += skyLightData.size(); - // return; + // std::vector skyLightData = std::vector(data->data + + // skyLightP, 16384); chunk->getSkyLightData(skyLightData); skyLightP + // += skyLightData.size(); return; //} bool bHasLower, bHasUpper; @@ -843,7 +843,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector blockData = std::vector(Level::CHUNK_TILE_COUNT); + std::vector blockData = + std::vector(Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData); for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) { @@ -851,7 +852,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vectordata() + blocksP); + std::copy(blockData.data() + slot, + blockData.data() + slot + len, + data->data() + blocksP); blocksP += len; } if (bHasUpper) { @@ -859,12 +862,15 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vectordata() + blocksP); + std::copy(blockData.data() + slot, + blockData.data() + slot + len, + data->data() + blocksP); blocksP += len; } } - std::vector dataData = std::vector(Level::CHUNK_TILE_COUNT); + std::vector dataData = + std::vector(Level::CHUNK_TILE_COUNT); chunk->getDataData(dataData); for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) { @@ -873,7 +879,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector> 1; int len = (lowerY1 - lowerY0) / 2; - std::copy(dataData.data() + slot, dataData.data() + slot + len, data->data() + dataP); + std::copy(dataData.data() + slot, dataData.data() + slot + len, + data->data() + dataP); dataP += len; } if (bHasUpper) { @@ -882,14 +889,16 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector> 1; int len = (upperY1 - upperY0) / 2; - std::copy(dataData.data() + slot, dataData.data() + slot + len, data->data() + dataP); + std::copy(dataData.data() + slot, dataData.data() + slot + len, + data->data() + dataP); dataP += len; } } // 4J Stu - Allow ignoring light data if (blockLightP > -1) { - std::vector blockLightData = std::vector(Level::HALF_CHUNK_TILE_COUNT); + std::vector blockLightData = + std::vector(Level::HALF_CHUNK_TILE_COUNT); chunk->getBlockLightData(blockLightData); for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) { @@ -898,7 +907,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector> 1; int len = (lowerY1 - lowerY0) / 2; - std::copy(blockLightData.data() + slot, blockLightData.data() + slot + len, data->data() + blockLightP); + std::copy(blockLightData.data() + slot, + blockLightData.data() + slot + len, + data->data() + blockLightP); blockLightP += len; } if (bHasUpper) { @@ -907,7 +918,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vectordata() + blockLightP); + std::copy(blockLightData.data() + slot, + blockLightData.data() + slot + len, + data->data() + blockLightP); blockLightP += len; } } @@ -915,7 +928,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector -1) { - std::vector skyLightData = std::vector(Level::HALF_CHUNK_TILE_COUNT); + std::vector skyLightData = + std::vector(Level::HALF_CHUNK_TILE_COUNT); chunk->getSkyLightData(skyLightData); for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) { @@ -924,7 +938,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector> 1; int len = (lowerY1 - lowerY0) / 2; - std::copy(skyLightData.data() + slot, skyLightData.data() + slot + len, data->data() + skyLightP); + std::copy(skyLightData.data() + slot, + skyLightData.data() + slot + len, + data->data() + skyLightP); skyLightP += len; } if (bHasUpper) { @@ -933,7 +949,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vectordata() + skyLightP); + std::copy(skyLightData.data() + slot, + skyLightData.data() + slot + len, + data->data() + skyLightP); skyLightP += len; } } @@ -943,9 +961,10 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector& blockData, std::vector& dataData, - std::vector inputData, int x0, int y0, int z0, int x1, int y1, int z1, - int& blocksP, int& dataP, int& blockLightP, int& skyLightP) { + LevelChunk* chunk, std::vector& blockData, + std::vector& dataData, std::vector inputData, int x0, + int y0, int z0, int x1, int y1, int z1, int& blocksP, int& dataP, + int& blockLightP, int& skyLightP) { bool bHasLower, bHasUpper; bHasLower = bHasUpper = false; int lowerY0, lowerY1, upperY0, upperY1; @@ -964,13 +983,15 @@ void ConsoleSchematicFile::setBlocksAndData( upperY1 = y1 - Level::COMPRESSED_CHUNK_SECTION_HEIGHT; bHasUpper = true; } - for (int x = x0; x < x1; x++) + for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) { if (bHasLower) { int slot = x << Level::genDepthBitsPlusFour | z << Level::genDepthBits | lowerY0; int len = lowerY1 - lowerY0; - std::copy(inputData.data() + blocksP, inputData.data() + blocksP + len, blockData.data() + slot); + std::copy(inputData.data() + blocksP, + inputData.data() + blocksP + len, + blockData.data() + slot); blocksP += len; } if (bHasUpper) { @@ -978,20 +999,23 @@ void ConsoleSchematicFile::setBlocksAndData( z << Level::genDepthBits | upperY0) + Level::COMPRESSED_CHUNK_SECTION_TILES; int len = upperY1 - upperY0; - std::copy(inputData.data() + blocksP, inputData.data() + blocksP + len, blockData.data() + slot); + std::copy(inputData.data() + blocksP, + inputData.data() + blocksP + len, + blockData.data() + slot); blocksP += len; } } - - for (int x = x0; x < x1; x++) + for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) { if (bHasLower) { int slot = (x << Level::genDepthBitsPlusFour | z << Level::genDepthBits | lowerY0) >> 1; int len = (lowerY1 - lowerY0) / 2; - std::copy(inputData.data() + dataP, inputData.data() + dataP + len, dataData.data() + slot); + std::copy(inputData.data() + dataP, + inputData.data() + dataP + len, + dataData.data() + slot); dataP += len; } if (bHasUpper) { @@ -1000,14 +1024,17 @@ void ConsoleSchematicFile::setBlocksAndData( Level::COMPRESSED_CHUNK_SECTION_TILES) >> 1; int len = (upperY1 - upperY0) / 2; - std::copy(inputData.data() + dataP, inputData.data() + dataP + len, dataData.data() + slot); + std::copy(inputData.data() + dataP, + inputData.data() + dataP + len, + dataData.data() + slot); dataP += len; } } - + // 4J Stu - Allow ignoring light data if (blockLightP > -1) { - std::vector blockLightData = std::vector(Level::HALF_CHUNK_TILE_COUNT); + std::vector blockLightData = + std::vector(Level::HALF_CHUNK_TILE_COUNT); chunk->getBlockLightData(blockLightData); for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) { @@ -1016,7 +1043,9 @@ void ConsoleSchematicFile::setBlocksAndData( z << Level::genDepthBits | lowerY0) >> 1; int len = (lowerY1 - lowerY0) / 2; - std::copy(inputData.data() + blockLightP, inputData.data() + blockLightP + len, blockLightData.data() + slot); + std::copy(inputData.data() + blockLightP, + inputData.data() + blockLightP + len, + blockLightData.data() + slot); blockLightP += len; } if (bHasUpper) { @@ -1025,7 +1054,9 @@ void ConsoleSchematicFile::setBlocksAndData( 1) + (Level::COMPRESSED_CHUNK_SECTION_TILES / 2); int len = (upperY1 - upperY0) / 2; - std::copy(inputData.data() + blockLightP, inputData.data() + blockLightP + len, blockLightData.data() + slot); + std::copy(inputData.data() + blockLightP, + inputData.data() + blockLightP + len, + blockLightData.data() + slot); blockLightP += len; } } @@ -1034,7 +1065,8 @@ void ConsoleSchematicFile::setBlocksAndData( // 4J Stu - Allow ignoring light data if (skyLightP > -1) { - std::vector skyLightData = std::vector(Level::HALF_CHUNK_TILE_COUNT); + std::vector skyLightData = + std::vector(Level::HALF_CHUNK_TILE_COUNT); chunk->getSkyLightData(skyLightData); for (int x = x0; x < x1; x++) for (int z = z0; z < z1; z++) { @@ -1043,7 +1075,9 @@ void ConsoleSchematicFile::setBlocksAndData( z << Level::genDepthBits | lowerY0) >> 1; int len = (lowerY1 - lowerY0) / 2; - std::copy(inputData.data() + skyLightP, inputData.data() + skyLightP + len, skyLightData.data() + slot); + std::copy(inputData.data() + skyLightP, + inputData.data() + skyLightP + len, + skyLightData.data() + slot); skyLightP += len; } if (bHasUpper) { @@ -1051,7 +1085,9 @@ void ConsoleSchematicFile::setBlocksAndData( z << Level::genDepthBits | upperY0) + (Level::COMPRESSED_CHUNK_SECTION_TILES / 2); int len = (upperY1 - upperY0) / 2; - std::copy(inputData.data() + skyLightP, inputData.data() + skyLightP + len, skyLightData.data() + slot); + std::copy(inputData.data() + skyLightP, + inputData.data() + skyLightP + len, + skyLightData.data() + slot); skyLightP += len; } } diff --git a/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ConsoleSchematicFile.h b/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ConsoleSchematicFile.h index 958283e76..111e4f383 100644 --- a/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ConsoleSchematicFile.h +++ b/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/ConsoleSchematicFile.h @@ -54,7 +54,7 @@ public: Compression::ECompressionTypes compressionType; _XboxSchematicInitParam() { - memset(name, 0, 64 * (sizeof(wchar_t))); + memset(name, 0, 64 * (sizeof(wchar_t))); startX = startY = startZ = endX = endY = endZ = 0; bSaveMobs = false; compressionType = Compression::eCompressionType_None; @@ -92,18 +92,19 @@ public: int xEnd, int yEnd, int zEnd, bool bSaveMobs, Compression::ECompressionTypes); - static void setBlocksAndData(LevelChunk* chunk, std::vector& blockData, - std::vector& dataData, std::vector data, int x0, - int y0, int z0, int x1, int y1, int z1, - int& blocksP, int& dataP, int& blockLightP, - int& skyLightP); + static void setBlocksAndData(LevelChunk* chunk, + std::vector& blockData, + std::vector& dataData, + std::vector data, int x0, int y0, + int z0, int x1, int y1, int z1, int& blocksP, + int& dataP, int& blockLightP, int& skyLightP); private: void save_tags(DataOutputStream* dos); void load_tags(DataInputStream* dis); - static void getBlocksAndData(LevelChunk* chunk, std::vector* data, int x0, - int y0, int z0, int x1, int y1, int z1, + static void getBlocksAndData(LevelChunk* chunk, std::vector* data, + int x0, int y0, int z0, int x1, int y1, int z1, int& blocksP, int& dataP, int& blockLightP, int& skyLightP); static std::vector >* getTileEntitiesInRegion( diff --git a/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/LevelGenerationOptions.cpp b/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/LevelGenerationOptions.cpp index f0f923a3b..d92049934 100644 --- a/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/LevelGenerationOptions.cpp +++ b/targets/Minecraft.Client/Common/src/GameRules/LevelGeneration/LevelGenerationOptions.cpp @@ -277,7 +277,6 @@ void LevelGenerationOptions::processSchematics(LevelChunk* chunk) { delete bb; } } - } void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) { @@ -288,12 +287,10 @@ void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) { ApplySchematicRuleDefinition* rule = *it; rule->processSchematicLighting(&chunkBox, chunk); } - } bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1) { - // As an optimisation, we can quickly discard things below a certain y which // makes most ore checks faster due to a) ores generally being below // ground/sea level and b) tutorial world additions generally being above @@ -337,7 +334,7 @@ bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1, if (intersects) break; } } - + return intersects; } @@ -513,7 +510,9 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr, if (fileHandle) { uint32_t dwFileSize = grf.length(); uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize]; - fileHandle.read(reinterpret_cast(pbData), static_cast(dwFileSize)); + fileHandle.read( + reinterpret_cast(pbData), + static_cast(dwFileSize)); if (!fileHandle) { app.FatalLoadError(); } @@ -540,7 +539,8 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr, if (saveHandle) { auto dwFileSize = std::filesystem::file_size(savePath); uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize]; - saveHandle.read(reinterpret_cast(pbData), static_cast(dwFileSize)); + saveHandle.read(reinterpret_cast(pbData), + static_cast(dwFileSize)); if (!saveHandle) { app.FatalLoadError(); } diff --git a/targets/Minecraft.Client/Common/src/Network/GameNetworkManager.cpp b/targets/Minecraft.Client/Common/src/Network/GameNetworkManager.cpp index 52897d7a0..6ae2c9ad0 100644 --- a/targets/Minecraft.Client/Common/src/Network/GameNetworkManager.cpp +++ b/targets/Minecraft.Client/Common/src/Network/GameNetworkManager.cpp @@ -144,11 +144,13 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft, std::ifstream fileHandle(grfPath, std::ios::binary); if (fileHandle) { - auto dwFileSize = std::filesystem::file_size(grfPath); + auto dwFileSize = + std::filesystem::file_size(grfPath); uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize]; - fileHandle.read(reinterpret_cast(pbData), - static_cast(dwFileSize)); + fileHandle.read( + reinterpret_cast(pbData), + static_cast(dwFileSize)); if (!fileHandle) { app.FatalLoadError(); } diff --git a/targets/Minecraft.Client/Common/src/Network/PlatformNetworkManagerInterface.h b/targets/Minecraft.Client/Common/src/Network/PlatformNetworkManagerInterface.h index 21eae2db7..2db2a2ab7 100644 --- a/targets/Minecraft.Client/Common/src/Network/PlatformNetworkManagerInterface.h +++ b/targets/Minecraft.Client/Common/src/Network/PlatformNetworkManagerInterface.h @@ -11,7 +11,6 @@ #include "NetworkPlayerInterface.h" #include "SessionInfo.h" - class ClientConnection; class Minecraft; class CGameNetworkManager; diff --git a/targets/Minecraft.Client/Common/src/Network/PlatformNetworkManagerStub.cpp b/targets/Minecraft.Client/Common/src/Network/PlatformNetworkManagerStub.cpp index 7c49252b4..34aca33ed 100644 --- a/targets/Minecraft.Client/Common/src/Network/PlatformNetworkManagerStub.cpp +++ b/targets/Minecraft.Client/Common/src/Network/PlatformNetworkManagerStub.cpp @@ -451,7 +451,7 @@ std::wstring CPlatformNetworkManagerStub::GatherRTTStats() { ((NetworkPlayerQNet*)GetPlayerByIndex(i))->GetQNetPlayer(); if (!pQNetPlayer->IsLocal()) { - memset(stat, 0, 32 * sizeof(wchar_t)); + memset(stat, 0, 32 * sizeof(wchar_t)); swprintf(stat, 32, L"%d: %d/", i, pQNetPlayer->GetCurrentRtt()); stats.append(stat); } diff --git a/targets/Minecraft.Client/Common/src/Network/Socket.cpp b/targets/Minecraft.Client/Common/src/Network/Socket.cpp index 5dc672b67..9ef70c367 100644 --- a/targets/Minecraft.Client/Common/src/Network/Socket.cpp +++ b/targets/Minecraft.Client/Common/src/Network/Socket.cpp @@ -81,7 +81,8 @@ Socket::Socket(bool response) { if (s_serverConnection != nullptr) { s_serverConnection->NewIncomingSocket(socket); } else { - fprintf(stderr, + fprintf( + stderr, "SOCKET: Warning - attempted to notify server of new incoming " "socket but s_serverConnection is nullptr\n"); } @@ -142,7 +143,8 @@ void Socket::pushDataToQueue(const std::uint8_t* pbData, std::size_t dataSize, if (!fromHost) queueIdx = SOCKET_SERVER_END; if (queueIdx != m_end && !m_hostLocal) { - fprintf(stderr, + fprintf( + stderr, "SOCKET: Error pushing data to queue. End is %d but queue idx id " "%d\n", m_end, queueIdx); @@ -177,9 +179,9 @@ InputStream* Socket::getInputStream(bool isServerConnection) { } else { if (s_hostInStream[m_end] == nullptr) { fprintf(stderr, - "SOCKET: Warning - s_hostInStream[%d] is nullptr in " - "getInputStream(); calling EnsureStreamsInitialised()\n", - m_end); + "SOCKET: Warning - s_hostInStream[%d] is nullptr in " + "getInputStream(); calling EnsureStreamsInitialised()\n", + m_end); EnsureStreamsInitialised(); } return s_hostInStream[m_end]; @@ -205,9 +207,9 @@ Socket::SocketOutputStream* Socket::getOutputStream(bool isServerConnection) { int outIdx = 1 - m_end; if (s_hostOutStream[outIdx] == nullptr) { fprintf(stderr, - "SOCKET: Warning - s_hostOutStream[%d] is nullptr in " - "getOutputStream(); calling EnsureStreamsInitialised()\n", - outIdx); + "SOCKET: Warning - s_hostOutStream[%d] is nullptr in " + "getOutputStream(); calling EnsureStreamsInitialised()\n", + outIdx); EnsureStreamsInitialised(); } return s_hostOutStream[outIdx]; @@ -275,7 +277,8 @@ int Socket::SocketInputStreamLocal::read(std::vector& b) { // Try and get an input range of bytes, blocking until enough bytes are // available -int Socket::SocketInputStreamLocal::read(std::vector& b, unsigned int offset, +int Socket::SocketInputStreamLocal::read(std::vector& b, + unsigned int offset, unsigned int length) { while (m_streamOpen) { { @@ -326,7 +329,8 @@ void Socket::SocketOutputStreamLocal::write(const std::vector& b) { write(b, 0, b.size()); } -void Socket::SocketOutputStreamLocal::write(const std::vector& b, unsigned int offset, +void Socket::SocketOutputStreamLocal::write(const std::vector& b, + unsigned int offset, unsigned int length) { if (m_streamOpen != true) { return; @@ -386,7 +390,8 @@ int Socket::SocketInputStreamNetwork::read(std::vector& b) { // Try and get an input range of bytes, blocking until enough bytes are // available -int Socket::SocketInputStreamNetwork::read(std::vector& b, unsigned int offset, +int Socket::SocketInputStreamNetwork::read(std::vector& b, + unsigned int offset, unsigned int length) { while (m_streamOpen) { { @@ -431,15 +436,15 @@ void Socket::SocketOutputStreamNetwork::write(const std::vector& b) { write(b, 0, b.size()); } -void Socket::SocketOutputStreamNetwork::write(const std::vector& b, unsigned int offset, +void Socket::SocketOutputStreamNetwork::write(const std::vector& b, + unsigned int offset, unsigned int length) { writeWithFlags(b, offset, length, 0); } -void Socket::SocketOutputStreamNetwork::writeWithFlags(const std::vector& b, - unsigned int offset, - unsigned int length, - int flags) { +void Socket::SocketOutputStreamNetwork::writeWithFlags( + const std::vector& b, unsigned int offset, unsigned int length, + int flags) { if (m_streamOpen != true) return; if (length == 0) return; @@ -467,15 +472,16 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(const std::vectorgetPlayer(); if (socketPlayer == nullptr) { fprintf(stderr, - "Trying to write to network, but the socketPlayer is " - "nullptr\n"); + "Trying to write to network, but the socketPlayer is " + "nullptr\n"); return; } diff --git a/targets/Minecraft.Client/Common/src/Network/Socket.h b/targets/Minecraft.Client/Common/src/Network/Socket.h index 99f911e61..6ae80c218 100644 --- a/targets/Minecraft.Client/Common/src/Network/Socket.h +++ b/targets/Minecraft.Client/Common/src/Network/Socket.h @@ -11,8 +11,8 @@ #include "java/InputOutputStream/InputStream.h" #include "java/InputOutputStream/OutputStream.h" -#include "console_helpers/C4JThread.h" // 4jcraft TODO -#include "console_helpers/ThreadName.h" // 4jcraft TODO +#include "console_helpers/C4JThread.h" // 4jcraft TODO +#include "console_helpers/ThreadName.h" // 4jcraft TODO #include "Minecraft.Client/Common/src/Network/NetworkPlayerInterface.h" #include "Minecraft.Client/Common/src/Network/GameNetworkManager.h" @@ -30,8 +30,9 @@ public: class SocketOutputStream : public OutputStream { public: // The flags are those that can be used for the QNet SendData function - virtual void writeWithFlags(const std::vector& b, unsigned int offset, - unsigned int length, int flags) { + virtual void writeWithFlags(const std::vector& b, + unsigned int offset, unsigned int length, + int flags) { write(b, offset, length); } }; @@ -49,7 +50,8 @@ private: virtual int read(); virtual int read(std::vector& b); - virtual int read(std::vector& b, unsigned int offset, unsigned int length); + virtual int read(std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual int64_t skip(int64_t n) { return n; @@ -85,7 +87,8 @@ private: virtual int read(); virtual int read(std::vector& b); - virtual int read(std::vector& b, unsigned int offset, unsigned int length); + virtual int read(std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual int64_t skip(int64_t n) { return n; @@ -104,8 +107,9 @@ private: virtual void write(const std::vector& b); virtual void write(const std::vector& b, unsigned int offset, unsigned int length); - virtual void writeWithFlags(const std::vector& b, unsigned int offset, - unsigned int length, int flags); + virtual void writeWithFlags(const std::vector& b, + unsigned int offset, unsigned int length, + int flags); virtual void close(); virtual void flush() {} }; diff --git a/targets/Minecraft.Client/Common/src/Tutorial/FullTutorial.cpp b/targets/Minecraft.Client/Common/src/Tutorial/FullTutorial.cpp index 34d65fc61..b37731e7d 100644 --- a/targets/Minecraft.Client/Common/src/Tutorial/FullTutorial.cpp +++ b/targets/Minecraft.Client/Common/src/Tutorial/FullTutorial.cpp @@ -184,11 +184,11 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/) // END OF BASIC TUTORIAL - addTask(e_Tutorial_State_Gameplay, - new ChoiceTask(this, IDS_TUTORIAL_TASK_BASIC_COMPLETE, - IDS_TUTORIAL_PROMPT_BASIC_COMPLETE, true, - ACTION_MENU_A, ACTION_MENU_B, - e_Tutorial_Completion_Jump_To_Last_Task)); + addTask( + e_Tutorial_State_Gameplay, + new ChoiceTask(this, IDS_TUTORIAL_TASK_BASIC_COMPLETE, + IDS_TUTORIAL_PROMPT_BASIC_COMPLETE, true, ACTION_MENU_A, + ACTION_MENU_B, e_Tutorial_Completion_Jump_To_Last_Task)); // START OF FULL TUTORIAL diff --git a/targets/Minecraft.Client/Common/src/Tutorial/Tasks/InfoTask.cpp b/targets/Minecraft.Client/Common/src/Tutorial/Tasks/InfoTask.cpp index 1b47b94e6..909fa666e 100644 --- a/targets/Minecraft.Client/Common/src/Tutorial/Tasks/InfoTask.cpp +++ b/targets/Minecraft.Client/Common/src/Tutorial/Tasks/InfoTask.cpp @@ -13,9 +13,8 @@ #include "Minecraft.Client/Common/src/Tutorial/Tasks/TutorialTask.h" #include "Minecraft.Client/Linux/Linux_UIController.h" -InfoTask::InfoTask( - Tutorial* tutorial, int descriptionId, int promptId /*= -1*/, - bool requiresUserInput /*= false*/, int iMapping /*= 0*/) +InfoTask::InfoTask(Tutorial* tutorial, int descriptionId, int promptId /*= -1*/, + bool requiresUserInput /*= false*/, int iMapping /*= 0*/) : TutorialTask(tutorial, descriptionId, false, nullptr, true, false, false) { if (requiresUserInput == true) { diff --git a/targets/Minecraft.Client/Common/src/Tutorial/Tasks/InfoTask.h b/targets/Minecraft.Client/Common/src/Tutorial/Tasks/InfoTask.h index 1323b23bb..e1cef7f97 100644 --- a/targets/Minecraft.Client/Common/src/Tutorial/Tasks/InfoTask.h +++ b/targets/Minecraft.Client/Common/src/Tutorial/Tasks/InfoTask.h @@ -15,9 +15,8 @@ private: bool CompletionMaskIsValid(); public: - InfoTask( - Tutorial* tutorial, int descriptionId, int promptId = -1, - bool requiresUserInput = false, int iMapping = 0); + InfoTask(Tutorial* tutorial, int descriptionId, int promptId = -1, + bool requiresUserInput = false, int iMapping = 0); virtual bool isCompleted(); virtual int getPromptId(); virtual void setAsCurrentTask(bool active = true); diff --git a/targets/Minecraft.Client/Common/src/Tutorial/Tutorial.cpp b/targets/Minecraft.Client/Common/src/Tutorial/Tutorial.cpp index 89acc28a1..f6b2c1a2b 100644 --- a/targets/Minecraft.Client/Common/src/Tutorial/Tutorial.cpp +++ b/targets/Minecraft.Client/Common/src/Tutorial/Tutorial.cpp @@ -1944,7 +1944,7 @@ void Tutorial::debugResetPlayerSavedProgress(int iPad) { GAME_SETTINGS* pGameSettings = (GAME_SETTINGS*)ProfileManager.GetGameDefinedProfileData(iPad); memset(pGameSettings->ucTutorialCompletion, 0, - TUTORIAL_PROFILE_STORAGE_BYTES); + TUTORIAL_PROFILE_STORAGE_BYTES); pGameSettings->uiSpecialTutorialBitmask = 0; } @@ -2366,8 +2366,8 @@ void Tutorial::tick() { } } - if (m_hintDisplayed && - (lastMessageTime + m_iTutorialDisplayMessageTime) < PlatformTime::GetTickCount()) { + if (m_hintDisplayed && (lastMessageTime + m_iTutorialDisplayMessageTime) < + PlatformTime::GetTickCount()) { m_hintDisplayed = false; } @@ -2402,7 +2402,8 @@ bool Tutorial::setMessage(PopupMessageDetails* message) { m_lastMessageState == m_CurrentState && message->isSameContent(m_lastMessage) && (!message->m_isReminder || - ((lastMessageTime + m_iTutorialReminderTime) > PlatformTime::GetTickCount() && + ((lastMessageTime + m_iTutorialReminderTime) > + PlatformTime::GetTickCount() && message->m_isReminder))) { delete message; return false; @@ -2412,7 +2413,8 @@ bool Tutorial::setMessage(PopupMessageDetails* message) { (message->m_messageId > 0 || !message->m_messageString.empty())) { m_lastMessageState = m_CurrentState; - if (!message->m_replaceCurrent) lastMessageTime = PlatformTime::GetTickCount(); + if (!message->m_replaceCurrent) + lastMessageTime = PlatformTime::GetTickCount(); std::wstring text; if (!message->m_messageString.empty()) { diff --git a/targets/Minecraft.Client/Common/src/UI/All Platforms/ArchiveFile.cpp b/targets/Minecraft.Client/Common/src/UI/All Platforms/ArchiveFile.cpp index 14e780f1d..710b81d1d 100644 --- a/targets/Minecraft.Client/Common/src/UI/All Platforms/ArchiveFile.cpp +++ b/targets/Minecraft.Client/Common/src/UI/All Platforms/ArchiveFile.cpp @@ -145,8 +145,8 @@ std::vector ArchiveFile::getFile(const std::wstring& filename) { uncompressedBuffer, &decompressedSize, out.data() + 4, out.size() - 4); - - out = std::vector(uncompressedBuffer, uncompressedBuffer + decompressedSize); + out = std::vector(uncompressedBuffer, + uncompressedBuffer + decompressedSize); delete[] uncompressedBuffer; } diff --git a/targets/Minecraft.Client/Common/src/UI/All Platforms/IUIScene_CraftingMenu.cpp b/targets/Minecraft.Client/Common/src/UI/All Platforms/IUIScene_CraftingMenu.cpp index 5cf51921d..aba1cf3be 100644 --- a/targets/Minecraft.Client/Common/src/UI/All Platforms/IUIScene_CraftingMenu.cpp +++ b/targets/Minecraft.Client/Common/src/UI/All Platforms/IUIScene_CraftingMenu.cpp @@ -630,7 +630,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() { } } */ - std::vector* recipes = ((Recipes*)Recipes::getInstance())->getRecipies(); + std::vector* recipes = + ((Recipes*)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); int iRecipeC = (int)recipes->size(); @@ -871,7 +872,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() { // run through the canbemade list and update the icons displayed int iIndex = 0; - // std::vector *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + // std::vector *recipes = ((Recipes + // *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); @@ -993,7 +995,8 @@ void IUIScene_CraftingMenu::UpdateHighlight() { // ////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::UpdateVerticalSlots() { - // std::vector *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + // std::vector *recipes = ((Recipes + // *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); @@ -1064,7 +1067,8 @@ void IUIScene_CraftingMenu::UpdateVerticalSlots() { // ////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::DisplayIngredients() { - // std::vector *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + // std::vector *recipes = ((Recipes + // *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); @@ -1231,7 +1235,8 @@ void IUIScene_CraftingMenu::DisplayIngredients() { ////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) { int iIDSString = 0; - // std::vector *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + // std::vector *recipes = ((Recipes + // *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); @@ -1319,7 +1324,8 @@ void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) { // ////////////////////////////////////////////////////////////////////////// void IUIScene_CraftingMenu::UpdateTooltips() { - // std::vector *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + // std::vector *recipes = ((Recipes + // *)Recipes::getInstance())->getRecipies(); Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipes::getInstance()->getRecipeIngredientsArray(); // Update tooltips diff --git a/targets/Minecraft.Client/Common/src/UI/All Platforms/IUIScene_PauseMenu.cpp b/targets/Minecraft.Client/Common/src/UI/All Platforms/IUIScene_PauseMenu.cpp index 7137b8b8d..84ad72317 100644 --- a/targets/Minecraft.Client/Common/src/UI/All Platforms/IUIScene_PauseMenu.cpp +++ b/targets/Minecraft.Client/Common/src/UI/All Platforms/IUIScene_PauseMenu.cpp @@ -1,7 +1,6 @@ #include #include - #include "IUIScene_PauseMenu.h" #include "Minecraft.Client/Common/src/UI/UIScene.h" #include "minecraft/client/Minecraft.h" diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LeaderboardsMenu.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LeaderboardsMenu.cpp index a9fc87de7..be5775687 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LeaderboardsMenu.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LeaderboardsMenu.cpp @@ -599,7 +599,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry( LeaderboardEntry* leaderboardEntry = &(m_leaderboard.m_entries[leaderboardEntryIndex]); - memset(leaderboardEntry, 0, sizeof(LeaderboardEntry)); + memset(leaderboardEntry, 0, sizeof(LeaderboardEntry)); leaderboardEntry->m_xuid = statsRow->m_uid; // Copy the rank @@ -635,7 +635,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry( // Copy the other columns for (unsigned int i = 0; i < statsRow->m_statsSize; i++) { leaderboardEntry->m_columns[i] = statsRow->m_statsData[i]; - memset(leaderboardEntry->m_wcColumns[i], 0, 12 * sizeof(wchar_t)); + memset(leaderboardEntry->m_wcColumns[i], 0, 12 * sizeof(wchar_t)); if (!isDistanceLeaderboard) { unsigned int displayValue = leaderboardEntry->m_columns[i]; if (displayValue > 99999) displayValue = 99999; diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp index 206998f9d..06e151a06 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LoadMenu.cpp @@ -270,7 +270,7 @@ void UIScene_LoadMenu::tick() { unsigned int uiHostOptions = 0; char szSeed[50]; - memset(szSeed, 0, 50); + memset(szSeed, 0, 50); app.GetImageTextData( m_pbThumbnailData, m_uiThumbnailSize, (unsigned char*)&szSeed, uiHostOptions, bHostOptionsRead, m_MoreOptionsParams.dwTexturePack); diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LoadOrJoinMenu.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LoadOrJoinMenu.cpp index 002844291..8df1252c8 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LoadOrJoinMenu.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_LoadOrJoinMenu.cpp @@ -1,7 +1,6 @@ #include #include - #include "Minecraft.Client/Common/src/UI/UI.h" #include "UIScene_LoadOrJoinMenu.h" @@ -1099,7 +1098,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() { } SessionID selectedSessionId; - memset(&selectedSessionId, 0, sizeof(SessionID)); + memset(&selectedSessionId, 0, sizeof(SessionID)); if (pSelectedSession != nullptr) selectedSessionId = pSelectedSession->sessionId; pSelectedSession = nullptr; @@ -1476,7 +1475,7 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned( // bring up a keyboard wchar_t wSaveName[128]; // CD - Fix - We must memset the SaveName - memset(wSaveName, 0, 128 * sizeof(wchar_t)); + memset(wSaveName, 0, 128 * sizeof(wchar_t)); mbstowcs( wSaveName, pClass @@ -1722,7 +1721,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { // on saving games that std::uint8_t bTextMetadata[88]; - memset(bTextMetadata, 0, 88); + memset(bTextMetadata, 0, 88); unsigned int hostOptions = app.getRemoteStorage()->getSaveHostOptions(); int iTextMetadataBytes = app.CreateImageTextData( @@ -1898,7 +1897,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) { // for use on saving games that std::uint8_t bTextMetadata[88]; - memset(bTextMetadata, 0, 88); + memset(bTextMetadata, 0, 88); unsigned int remoteHostOptions = app.getRemoteStorage()->getSaveHostOptions(); app.SetGameHostOption(eGameHostOption_All, diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp index f78694c6c..2fae140dc 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_MainMenu.cpp @@ -10,7 +10,6 @@ #include "minecraft/client/Minecraft.h" #include "UIScene_MainMenu.h" - Random* UIScene_MainMenu::random = new Random(); int UIScene_MainMenu::eNavigateWhenReady = -1; @@ -242,13 +241,13 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) { &UIScene_MainMenu::UnlockFullGame_SignInReturned; break; case eControl_Exit: { - unsigned int uiIDA[2]; - uiIDA[0] = IDS_CONFIRM_CANCEL; - uiIDA[1] = IDS_CONFIRM_OK; - ui.RequestErrorMessage( - IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, - XUSER_INDEX_ANY, &UIScene_MainMenu::ExitGameReturned, this); - } break; + unsigned int uiIDA[2]; + uiIDA[0] = IDS_CONFIRM_CANCEL; + uiIDA[1] = IDS_CONFIRM_OK; + ui.RequestErrorMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, + 2, XUSER_INDEX_ANY, + &UIScene_MainMenu::ExitGameReturned, this); + } break; default: __debugbreak(); @@ -303,8 +302,7 @@ void UIScene_MainMenu::RunAction(int iPad) { void UIScene_MainMenu::customDraw(IggyCustomDrawCallbackRegion* region) { if (std::char_traits::compare(region->name, u"Splash", 6) == 0) { - customDrawSplash(region); - + customDrawSplash(region); } } @@ -341,7 +339,7 @@ void UIScene_MainMenu::customDrawSplash(IggyCustomDrawCallbackRegion* region) { glRotatef(-17, 0, 0, 1); float sss = 1.8f - std::abs(sinf(System::currentTimeMillis() % 1000 / - 1000.0f * std::numbers::pi * 2) * + 1000.0f * std::numbers::pi * 2) * 0.1f); sss *= (m_fScreenWidth / m_fRawWidth); @@ -874,10 +872,10 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { // you can't see the store unsigned int uiIDA[1]; uiIDA[0] = IDS_CONFIRM_OK; - ui.RequestErrorMessage( - IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, - uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, - this); + ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE, + IDS_CONTENT_RESTRICTION, uiIDA, 1, + ProfileManager.GetPrimaryPad(), + nullptr, this); #endif } else { ProfileManager.SetLockedProfile(iPad); @@ -897,8 +895,8 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) { } else { unsigned int uiIDA[1]; uiIDA[0] = IDS_OK; - ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, - IDS_PRO_NOTONLINE_TEXT, uiIDA, 1); + ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT, + uiIDA, 1); } } diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_TrialExitUpsell.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_TrialExitUpsell.cpp index 1360a6e97..51e372873 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_TrialExitUpsell.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/Frontend Menu screens/UIScene_TrialExitUpsell.cpp @@ -42,7 +42,6 @@ void UIScene_TrialExitUpsell::handleInput(int iPad, int key, bool repeat, if (ProfileManager.IsSignedIn(iPad)) { // CD - Added for audio ui.PlayUISFX(eSFX_Press); - } break; } diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_Credits.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_Credits.cpp index b39fa3073..7a6abad60 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_Credits.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_Credits.cpp @@ -237,7 +237,7 @@ void UIScene_Credits::tick() { wchar_t* creditsString = new wchar_t[128]; if (pDef->m_iStringID[0] == NO_TRANSLATED_STRING) { - memset(creditsString, 0, 128); + memset(creditsString, 0, 128); memcpy(creditsString, sanitisedString.c_str(), sizeof(wchar_t) * sanitisedString.length()); } else if (pDef->m_iStringID[1] != NO_TRANSLATED_STRING) { diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_LanguageSelector.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_LanguageSelector.cpp index 948965abe..5134d50e9 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_LanguageSelector.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_LanguageSelector.cpp @@ -5,32 +5,31 @@ #include "UIScene_LanguageSelector.h" // strings for buttons in the list -const unsigned int UIScene_LanguageSelector::m_uiHTPButtonNameA[]= -{ - IDS_LANG_SYSTEM, - IDS_LANG_ENGLISH, - IDS_LANG_GERMAN, - IDS_LANG_SPANISH_SPAIN, - IDS_LANG_SPANISH_LATIN_AMERICA, - IDS_LANG_FRENCH, - IDS_LANG_ITALIAN, - IDS_LANG_PORTUGUESE_PORTUGAL, - IDS_LANG_PORTUGUESE_BRAZIL, - IDS_LANG_JAPANESE, - IDS_LANG_KOREAN, - IDS_LANG_CHINESE_TRADITIONAL, - IDS_LANG_CHINESE_SIMPLIFIED, - IDS_LANG_DANISH, - IDS_LANG_FINISH, - IDS_LANG_DUTCH, - IDS_LANG_POLISH, - IDS_LANG_RUSSIAN, - IDS_LANG_SWEDISH, - IDS_LANG_NORWEGIAN, - // IDS_LANG_SLOVAK, - // IDS_LANG_CZECH, - IDS_LANG_GREEK, - IDS_LANG_TURKISH, +const unsigned int UIScene_LanguageSelector::m_uiHTPButtonNameA[] = { + IDS_LANG_SYSTEM, + IDS_LANG_ENGLISH, + IDS_LANG_GERMAN, + IDS_LANG_SPANISH_SPAIN, + IDS_LANG_SPANISH_LATIN_AMERICA, + IDS_LANG_FRENCH, + IDS_LANG_ITALIAN, + IDS_LANG_PORTUGUESE_PORTUGAL, + IDS_LANG_PORTUGUESE_BRAZIL, + IDS_LANG_JAPANESE, + IDS_LANG_KOREAN, + IDS_LANG_CHINESE_TRADITIONAL, + IDS_LANG_CHINESE_SIMPLIFIED, + IDS_LANG_DANISH, + IDS_LANG_FINISH, + IDS_LANG_DUTCH, + IDS_LANG_POLISH, + IDS_LANG_RUSSIAN, + IDS_LANG_SWEDISH, + IDS_LANG_NORWEGIAN, + // IDS_LANG_SLOVAK, + // IDS_LANG_CZECH, + IDS_LANG_GREEK, + IDS_LANG_TURKISH, }; UIScene_LanguageSelector::UIScene_LanguageSelector(int iPad, void* initData, diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_LanguageSelector.h b/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_LanguageSelector.h index 5b4d52d8d..5bfbf6440 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_LanguageSelector.h +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/Help & Options/UIScene_LanguageSelector.h @@ -8,35 +8,34 @@ class UIScene_LanguageSelector : public UIScene { public: - enum ELangButtons - { - eLanguageSelector_LabelNone = -1, - eLanguageSelector_system, - eLanguageSelector_EN_US, - eLanguageSelector_DE_DE, - eLanguageSelector_ES_ES, - eLanguageSelector_ES_MX, - eLanguageSelector_FR_FR, - eLanguageSelector_IT_IT, - eLanguageSelector_PT_PT, - eLanguageSelector_PT_BR, - eLanguageSelector_JA_JP, - eLanguageSelector_KO_KR, - eLanguageSelector_CN_TW, - eLanguageSelector_CN_CN, - eLanguageSelector_DA_DK, - eLanguageSelector_FI_FI, - eLanguageSelector_NL_NL, - eLanguageSelector_PL_PL, - eLanguageSelector_RU_RU, - eLanguageSelector_SV_SE, - eLanguageSelector_NB_NO, - eLanguageSelector_SK_SK, - eLanguageSelector_CZ_CZ, - eLanguageSelector_EL_GR, - eLanguageSelector_TR_TR, - eLanguageSelector_MAX - }; + enum ELangButtons { + eLanguageSelector_LabelNone = -1, + eLanguageSelector_system, + eLanguageSelector_EN_US, + eLanguageSelector_DE_DE, + eLanguageSelector_ES_ES, + eLanguageSelector_ES_MX, + eLanguageSelector_FR_FR, + eLanguageSelector_IT_IT, + eLanguageSelector_PT_PT, + eLanguageSelector_PT_BR, + eLanguageSelector_JA_JP, + eLanguageSelector_KO_KR, + eLanguageSelector_CN_TW, + eLanguageSelector_CN_CN, + eLanguageSelector_DA_DK, + eLanguageSelector_FI_FI, + eLanguageSelector_NL_NL, + eLanguageSelector_PL_PL, + eLanguageSelector_RU_RU, + eLanguageSelector_SV_SE, + eLanguageSelector_NB_NO, + eLanguageSelector_SK_SK, + eLanguageSelector_CZ_CZ, + eLanguageSelector_EL_GR, + eLanguageSelector_TR_TR, + eLanguageSelector_MAX + }; private: enum EControls { @@ -73,58 +72,28 @@ protected: void handlePress(F64 controlId, F64 childId); }; -const int uiLangMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = -{ - MINECRAFT_LANGUAGE_DEFAULT, - XC_LANGUAGE_ENGLISH, - XC_LANGUAGE_GERMAN, - XC_LANGUAGE_SPANISH, - XC_LANGUAGE_SPANISH, - XC_LANGUAGE_FRENCH, - XC_LANGUAGE_ITALIAN, - XC_LANGUAGE_PORTUGUESE, - XC_LANGUAGE_PORTUGUESE, - XC_LANGUAGE_JAPANESE, - XC_LANGUAGE_KOREAN, - XC_LANGUAGE_TCHINESE, - XC_LANGUAGE_SCHINESE, - XC_LANGUAGE_DANISH, - XC_LANGUAGE_FINISH, - XC_LANGUAGE_DUTCH, - XC_LANGUAGE_POLISH, - XC_LANGUAGE_RUSSIAN, - XC_LANGUAGE_SWEDISH, - XC_LANGUAGE_BNORWEGIAN, - XC_LANGUAGE_SLOVAK, - XC_LANGUAGE_CZECH, - XC_LANGUAGE_GREEK, - XC_LANGUAGE_TURKISH, +const int uiLangMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = { + MINECRAFT_LANGUAGE_DEFAULT, XC_LANGUAGE_ENGLISH, XC_LANGUAGE_GERMAN, + XC_LANGUAGE_SPANISH, XC_LANGUAGE_SPANISH, XC_LANGUAGE_FRENCH, + XC_LANGUAGE_ITALIAN, XC_LANGUAGE_PORTUGUESE, XC_LANGUAGE_PORTUGUESE, + XC_LANGUAGE_JAPANESE, XC_LANGUAGE_KOREAN, XC_LANGUAGE_TCHINESE, + XC_LANGUAGE_SCHINESE, XC_LANGUAGE_DANISH, XC_LANGUAGE_FINISH, + XC_LANGUAGE_DUTCH, XC_LANGUAGE_POLISH, XC_LANGUAGE_RUSSIAN, + XC_LANGUAGE_SWEDISH, XC_LANGUAGE_BNORWEGIAN, XC_LANGUAGE_SLOVAK, + XC_LANGUAGE_CZECH, XC_LANGUAGE_GREEK, XC_LANGUAGE_TURKISH, }; -const int uiLocaleMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = -{ - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - XC_LOCALE_SPAIN, - XC_LOCALE_LATIN_AMERICA, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - XC_LOCALE_PORTUGAL, - XC_LOCALE_BRAZIL, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, - MINECRAFT_LANGUAGE_DEFAULT, +const int uiLocaleMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = { + MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, XC_LOCALE_SPAIN, + XC_LOCALE_LATIN_AMERICA, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, XC_LOCALE_PORTUGAL, + XC_LOCALE_BRAZIL, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, + MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, }; \ No newline at end of file diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_DeathMenu.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_DeathMenu.cpp index e216176d2..ed6b1301c 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_DeathMenu.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_DeathMenu.cpp @@ -117,8 +117,7 @@ void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) { ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, - m_iPad, - &IUIScene_PauseMenu::ExitGameDialogReturned, + m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned, (void*)GetCallbackUniqueId()); } } diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_EndPoem.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_EndPoem.cpp index 42dbc95f6..73ba75764 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_EndPoem.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_EndPoem.cpp @@ -235,7 +235,7 @@ void UIScene_EndPoem::updateNoise() { colour = eHTMLColor_9; else if (randomVal == 2) colour = eHTMLColor_a; - memset(replacements, 0, 64 * sizeof(wchar_t)); + memset(replacements, 0, 64 * sizeof(wchar_t)); swprintf( replacements, 64, L"%ls", diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_PauseMenu.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_PauseMenu.cpp index 9fb9316ca..2efd7df74 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_PauseMenu.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/In-Game Menu Screens/UIScene_PauseMenu.cpp @@ -91,7 +91,8 @@ void UIScene_PauseMenu::tick() { UIScene::tick(); } void UIScene_PauseMenu::updateTooltips() { // bool bUserisClientSide = ProfileManager.IsSignedInLive(m_iPad); // bool bIsisPrimaryHost = - // g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad() == m_iPad); + // g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad() == + // m_iPad); int iY = -1; int iRB = -1; @@ -333,15 +334,13 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, uiIDA, 3, m_iPad, - &UIScene_PauseMenu:: - ExitGameSaveDialogReturned, + &UIScene_PauseMenu::ExitGameSaveDialogReturned, (void*)GetCallbackUniqueId()); } else { ui.RequestAlertMessage( - IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, - 3, m_iPad, - &UIScene_PauseMenu:: - ExitGameSaveDialogReturned, + IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3, + m_iPad, + &UIScene_PauseMenu::ExitGameSaveDialogReturned, (void*)GetCallbackUniqueId()); } } else { @@ -350,8 +349,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) { ui.RequestAlertMessage( IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, - m_iPad, - &IUIScene_PauseMenu::ExitGameDialogReturned, + m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned, (void*)GetCallbackUniqueId()); } } diff --git a/targets/Minecraft.Client/Common/src/UI/Scenes/UIScene_Keyboard.cpp b/targets/Minecraft.Client/Common/src/UI/Scenes/UIScene_Keyboard.cpp index cb82ce51e..851871c3b 100644 --- a/targets/Minecraft.Client/Common/src/UI/Scenes/UIScene_Keyboard.cpp +++ b/targets/Minecraft.Client/Common/src/UI/Scenes/UIScene_Keyboard.cpp @@ -5,7 +5,6 @@ #include "console_helpers/StringHelpers.h" - #define KEYBOARD_DONE_TIMER_ID 0 #define KEYBOARD_DONE_TIMER_TIME 100 diff --git a/targets/Minecraft.Client/Common/src/UI/UIController.cpp b/targets/Minecraft.Client/Common/src/UI/UIController.cpp index 4de1e641e..957b356d1 100644 --- a/targets/Minecraft.Client/Common/src/UI/UIController.cpp +++ b/targets/Minecraft.Client/Common/src/UI/UIController.cpp @@ -316,17 +316,20 @@ UIController::EFont UIController::getFontForLanguage(int language) { UITTFFont* UIController::createFont(EFont fontLanguage) { switch (fontLanguage) { case eFont_Japanese: - return new UITTFFont("Mojangles_TTF_jaJP", - "Minecraft.Client/Common/Media/font/JPN/DFGMaruGothic-Md.ttf", - 0x2022); // JPN + return new UITTFFont( + "Mojangles_TTF_jaJP", + "Minecraft.Client/Common/Media/font/JPN/DFGMaruGothic-Md.ttf", + 0x2022); // JPN case eFont_TradChinese: - return new UITTFFont("Mojangles_TTF_cnTD", - "Minecraft.Client/Common/Media/font/CHT/DFHeiMedium-B5.ttf", - 0x2022); // CHT + return new UITTFFont( + "Mojangles_TTF_cnTD", + "Minecraft.Client/Common/Media/font/CHT/DFHeiMedium-B5.ttf", + 0x2022); // CHT case eFont_Korean: - return new UITTFFont("Mojangles_TTF_koKR", - "Minecraft.Client/Common/Media/font/KOR/BOKMSD.ttf", - 0x2022); // KOR + return new UITTFFont( + "Mojangles_TTF_koKR", + "Minecraft.Client/Common/Media/font/KOR/BOKMSD.ttf", + 0x2022); // KOR // 4J-JEV, Cyrillic characters have been added to this font now, // (4/July/14) XC_LANGUAGE_RUSSIAN and XC_LANGUAGE_GREEK: default: @@ -795,20 +798,16 @@ UIController::ExternalFunctionCallback(void* user_callback_data, Iggy* player, // RENDERING void UIController::renderScenes() { - // Only render player scenes if the game is started + // Only render player scenes if the game is started if (app.GetGameStarted() && !m_groups[eUIGroup_Fullscreen]->hidesLowerScenes()) { for (int i = eUIGroup_Player1; i < eUIGroup_COUNT; ++i) { - m_groups[i]->render(); - + m_groups[i]->render(); } } // Always render the fullscreen group - m_groups[eUIGroup_Fullscreen]->render(); - - - + m_groups[eUIGroup_Fullscreen]->render(); #if defined(ENABLE_IGGY_PERFMON) if (m_iggyPerfmonEnabled) { @@ -939,8 +938,8 @@ void UIController::setupCustomDrawGameState() { m_customRenderingClearRect.bottom = LONG_MIN; #if defined(_WINDOWS64) - RenderManager.StartFrame(); - + RenderManager.StartFrame(); + gdraw_D3D11_setViewport_4J(); #elif defined(__linux__) RenderManager.StartFrame(); @@ -953,7 +952,7 @@ void UIController::setupCustomDrawGameState() { // RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &m_customRenderingClearRect); // glClear(GL_DEPTH_BUFFER_BIT); - glMatrixMode(GL_PROJECTION); + glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(0, m_fScreenWidth, m_fScreenHeight, 0, 1000, 3000); glMatrixMode(GL_MODELVIEW); @@ -962,7 +961,6 @@ void UIController::setupCustomDrawGameState() { glEnable(GL_DEPTH_TEST); glDepthFunc(GL_LEQUAL); glDepthMask(true); - } void UIController::setupCustomDrawMatrices(UIScene* scene, @@ -1142,7 +1140,8 @@ void UIController::registerSubstitutionTexture(const std::wstring& textureName, // Remove it if it already exists unregisterSubstitutionTexture(textureName, false); - m_substitutionTextures[textureName] = std::vector(pbData, pbData + dwLength); + m_substitutionTextures[textureName] = + std::vector(pbData, pbData + dwLength); } void UIController::unregisterSubstitutionTexture( diff --git a/targets/Minecraft.Client/Common/src/UI/UIController.h b/targets/Minecraft.Client/Common/src/UI/UIController.h index 9ba5e0d2f..54235d42f 100644 --- a/targets/Minecraft.Client/Common/src/UI/UIController.h +++ b/targets/Minecraft.Client/Common/src/UI/UIController.h @@ -147,7 +147,8 @@ private: static std::uint32_t m_dwTrialTimerLimitSecs; - std::unordered_map> m_substitutionTextures; + std::unordered_map> + m_substitutionTextures; typedef struct _CachedMovieData { std::vector m_ba; diff --git a/targets/Minecraft.Client/Common/src/UI/UILayer.cpp b/targets/Minecraft.Client/Common/src/UI/UILayer.cpp index e1ca25ba9..92f12068a 100644 --- a/targets/Minecraft.Client/Common/src/UI/UILayer.cpp +++ b/targets/Minecraft.Client/Common/src/UI/UILayer.cpp @@ -145,7 +145,6 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) { if (itRef != m_componentRefCount.end() && itRef->second.second) { if ((*it)->isVisible()) { (*it)->render(width, height, viewport); - } } } @@ -162,7 +161,6 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) { m_sceneStack[lowestRenderable]->getSceneType() == eUIScene_Timer)) { m_sceneStack[lowestRenderable]->render(width, height, viewport); - } } } diff --git a/targets/Minecraft.Client/Common/src/UI/UIScene.cpp b/targets/Minecraft.Client/Common/src/UI/UIScene.cpp index 360734bf1..d3ed3ddd8 100644 --- a/targets/Minecraft.Client/Common/src/UI/UIScene.cpp +++ b/targets/Minecraft.Client/Common/src/UI/UIScene.cpp @@ -547,7 +547,7 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region, // Setup GDraw, normal game render states and matrices // CustomDrawData *customDrawRegion = // ui.setupCustomDraw(this,region); - CustomDrawData* customDrawRegion = + CustomDrawData* customDrawRegion = ui.calculateCustomDraw(region); ui.beginIggyCustomDraw4J(region, customDrawRegion); ui.setupCustomDrawGameState(); @@ -558,14 +558,13 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region, if (!useCommandBuffers || m_needsCacheRendered) { if (useCommandBuffers) RenderManager.CBuffStart(list, true); - ui.setupCustomDrawMatrices(this, customDrawRegion); + ui.setupCustomDrawMatrices(this, customDrawRegion); _customDrawSlotControl(customDrawRegion, iPad, item, fAlpha, isFoil, bDecorations, useCommandBuffers); delete customDrawRegion; - - // Draw all the cached slots + // Draw all the cached slots for (auto it = m_cachedSlotDraw.begin(); it != m_cachedSlotDraw.end(); ++it) { CachedSlotDrawData* drawData = *it; @@ -578,7 +577,7 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region, delete drawData->customDrawRegion; delete drawData; } - + if (useCommandBuffers) RenderManager.CBuffEnd(); } m_cachedSlotDraw.clear(); @@ -590,7 +589,7 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region, pMinecraft->player = oldPlayer; } else { - CachedSlotDrawData* drawData = new CachedSlotDrawData(); + CachedSlotDrawData* drawData = new CachedSlotDrawData(); drawData->item = item; drawData->fAlpha = fAlpha; drawData->isFoil = isFoil; @@ -598,7 +597,6 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region, drawData->customDrawRegion = ui.calculateCustomDraw(region); m_cachedSlotDraw.push_back(drawData); - } } else { // Setup GDraw, normal game render states and matrices @@ -676,11 +674,10 @@ void UIScene::_customDrawSlotControl(CustomDrawData* region, int iPad, glTranslatef((float)-(sx + sxoffs), (float)-(sy + syoffs), 0); } - if (m_pItemRenderer == nullptr) m_pItemRenderer = new ItemRenderer(); + if (m_pItemRenderer == nullptr) m_pItemRenderer = new ItemRenderer(); m_pItemRenderer->renderAndDecorateItem( pMinecraft->font, pMinecraft->textures, item, x, y, scaleX, scaleY, fAlpha, isFoil, false, !usingCommandBuffer); - if (pop > 0) { glPopMatrix(); diff --git a/targets/Minecraft.Client/Linux/Linux_App.cpp b/targets/Minecraft.Client/Linux/Linux_App.cpp index cef2ffcab..619c6e7b3 100644 --- a/targets/Minecraft.Client/Linux/Linux_App.cpp +++ b/targets/Minecraft.Client/Linux/Linux_App.cpp @@ -21,8 +21,7 @@ CConsoleMinecraftApp app; CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() {} -void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) { -} +void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) {} void CConsoleMinecraftApp::StoreLaunchData() {} void CConsoleMinecraftApp::ExitGame() { diff --git a/targets/Minecraft.Client/Linux/Linux_Minecraft.cpp b/targets/Minecraft.Client/Linux/Linux_Minecraft.cpp index 11464141e..db5b36fbe 100644 --- a/targets/Minecraft.Client/Linux/Linux_Minecraft.cpp +++ b/targets/Minecraft.Client/Linux/Linux_Minecraft.cpp @@ -547,7 +547,7 @@ int32_t InitDevice() { uint32_t numFeatureLevels = ARRAYSIZE(featureLevels); DXGI_SWAP_CHAIN_DESC sd; - memset(&sd, 0, sizeof(sd)); + memset(&sd, 0, sizeof(sd)); sd.BufferCount = 1; sd.BufferDesc.Width = width; sd.BufferDesc.Height = height; @@ -763,25 +763,22 @@ int main(int argc, const char* argv[]) { ui.setScreenSize(fbw, fbh); } app.UpdateTime(); - InputManager.Tick(); - - ProfileManager.Tick(); - - StorageManager.Tick(); - - RenderManager.Tick(); - + InputManager.Tick(); + + ProfileManager.Tick(); + + StorageManager.Tick(); + + RenderManager.Tick(); // Tick the social networking manager. - // CSocialManager::Instance()->Tick(); - + // CSocialManager::Instance()->Tick(); // Tick sentient. - // SentientManager.Tick(); - + // SentientManager.Tick(); + + g_NetworkManager.DoWork(); - g_NetworkManager.DoWork(); - // Render game graphics. #if defined(ENABLE_JAVA_GUIS) pMinecraft->run_middle(); @@ -824,7 +821,7 @@ int main(int argc, const char* argv[]) { RenderManager.Present(); ui.CheckMenuDisplayed(); - // has the game defined profile data been changed (by a profile load) + // has the game defined profile data been changed (by a profile load) if (app.uiGameDefinedDataChangedBitmask != 0) { void* pData; for (int i = 0; i < XUSER_MAX_COUNT; i++) { @@ -855,10 +852,8 @@ int main(int argc, const char* argv[]) { // clear the flag app.uiGameDefinedDataChangedBitmask = 0; } - - g_NetworkManager.DoWork(); - + g_NetworkManager.DoWork(); // Any threading type things to deal with from the xui side? app.HandleXuiActions(); diff --git a/targets/Minecraft.Client/Linux/Linux_UIController.cpp b/targets/Minecraft.Client/Linux/Linux_UIController.cpp index 21c4b96bf..66a76a8db 100644 --- a/targets/Minecraft.Client/Linux/Linux_UIController.cpp +++ b/targets/Minecraft.Client/Linux/Linux_UIController.cpp @@ -8,7 +8,6 @@ #include "Minecraft.Client/Linux/Linux_App.h" #include "Minecraft.Client/Linux/Iggy/gdraw/gdraw.h" - ConsoleUIController ui; static void restoreFixedFunctionStateAfterIggy() { diff --git a/targets/Minecraft.Client/Windows64/Source Files/Windows64_Minecraft.cpp b/targets/Minecraft.Client/Windows64/Source Files/Windows64_Minecraft.cpp index 7983a0f2d..4b966d5db 100644 --- a/targets/Minecraft.Client/Windows64/Source Files/Windows64_Minecraft.cpp +++ b/targets/Minecraft.Client/Windows64/Source Files/Windows64_Minecraft.cpp @@ -1,8 +1,6 @@ // Minecraft.cpp : Defines the entry point for the application. // - - #include #include #include "minecraft/server/MinecraftServer.h" @@ -564,7 +562,7 @@ int32_t InitDevice() { uint32_t numFeatureLevels = ARRAYSIZE(featureLevels); DXGI_SWAP_CHAIN_DESC sd; - memset(&sd, 0, sizeof(sd)); + memset(&sd, 0, sizeof(sd)); sd.BufferCount = 1; sd.BufferDesc.Width = width; sd.BufferDesc.Height = height; @@ -789,25 +787,21 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, // } app.UpdateTime(); - InputManager.Tick(); - - // ProfileManager.Tick(); - - StorageManager.Tick(); - - RenderManager.Tick(); - + InputManager.Tick(); + + // ProfileManager.Tick(); + + StorageManager.Tick(); + + RenderManager.Tick(); // Tick the social networking manager. - // CSocialManager::Instance()->Tick(); - + // CSocialManager::Instance()->Tick(); // Tick sentient. - // SentientManager.Tick(); - + // SentientManager.Tick(); - // g_NetworkManager.DoWork(); - + // g_NetworkManager.DoWork(); // LeaderboardManager::Instance()->Tick(); // Render game graphics. diff --git a/targets/Minecraft.Client/Windows64/Windows64_UIController.cpp b/targets/Minecraft.Client/Windows64/Windows64_UIController.cpp index f7aaea330..2f33835f5 100644 --- a/targets/Minecraft.Client/Windows64/Windows64_UIController.cpp +++ b/targets/Minecraft.Client/Windows64/Windows64_UIController.cpp @@ -97,11 +97,9 @@ void ConsoleUIController::render() { void ConsoleUIController::beginIggyCustomDraw4J( IggyCustomDrawCallbackRegion* region, CustomDrawData* customDrawRegion) { - - // get the correct object-to-world matrix from GDraw, and set the render + // get the correct object-to-world matrix from GDraw, and set the render // state to a normal state gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat); - } CustomDrawData* ConsoleUIController::setupCustomDraw( @@ -112,7 +110,7 @@ CustomDrawData* ConsoleUIController::setupCustomDraw( customDrawRegion->y0 = region->y0; customDrawRegion->y1 = region->y1; - // get the correct object-to-world matrix from GDraw, and set the render + // get the correct object-to-world matrix from GDraw, and set the render // state to a normal state gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat); @@ -138,7 +136,6 @@ void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion* region) { endCustomDrawGameStateAndMatrices(); gdraw_D3D11_EndCustomDraw(region); - } void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) { diff --git a/targets/Minecraft.Client/Windows64/XML/xmlFilesCallback.h b/targets/Minecraft.Client/Windows64/XML/xmlFilesCallback.h index 4f58aa799..220febb6f 100644 --- a/targets/Minecraft.Client/Windows64/XML/xmlFilesCallback.h +++ b/targets/Minecraft.Client/Windows64/XML/xmlFilesCallback.h @@ -38,7 +38,7 @@ public: pAttributes[i].ValueLen); } else if (_wcsicmp(wAttName, L"xuid") == 0) { if (pAttributes[i].ValueLen <= 32) { - memset(wTemp, 0, sizeof(wchar_t) * 35); + memset(wTemp, 0, sizeof(wchar_t) * 35); wcsncpy_s(wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); xuid = _wcstoui64(wTemp, nullptr, 10); @@ -203,7 +203,7 @@ public: pAttributes[i].NameLen); if (_wcsicmp(wAttName, L"SortIndex") == 0) { if (pAttributes[i].ValueLen <= 32) { - memset(wTemp, 0, sizeof(wchar_t) * 35); + memset(wTemp, 0, sizeof(wchar_t) * 35); wcsncpy_s(wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); uiSortIndex = wcstoul(wTemp, nullptr, 16); @@ -215,14 +215,14 @@ public: } } else if (_wcsicmp(wAttName, L"Full") == 0) { if (pAttributes[i].ValueLen <= 32) { - memset(wTemp, 0, sizeof(wchar_t) * 35); + memset(wTemp, 0, sizeof(wchar_t) * 35); wcsncpy_s(wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); ullFull = _wcstoui64(wTemp, nullptr, 16); } } else if (_wcsicmp(wAttName, L"Trial") == 0) { if (pAttributes[i].ValueLen <= 32) { - memset(wTemp, 0, sizeof(wchar_t) * 35); + memset(wTemp, 0, sizeof(wchar_t) * 35); wcsncpy_s(wTemp, pAttributes[i].strValue, pAttributes[i].ValueLen); ullTrial = _wcstoui64(wTemp, nullptr, 16); diff --git a/targets/Minecraft.Client/include/BufferedImage.h b/targets/Minecraft.Client/include/BufferedImage.h index 022a4150b..df3a6a3f0 100644 --- a/targets/Minecraft.Client/include/BufferedImage.h +++ b/targets/Minecraft.Client/include/BufferedImage.h @@ -26,10 +26,11 @@ public: int getWidth(); int getHeight(); - void getRGB(int startX, int startY, int w, int h, std::vector& out, int offset, - int scansize, int level = 0); // 4J Added level param - int* getData(); // 4J added - int* getData(int level); // 4J added + void getRGB(int startX, int startY, int w, int h, std::vector& out, + int offset, int scansize, + int level = 0); // 4J Added level param + int* getData(); // 4J added + int* getData(int level); // 4J added Graphics* getGraphics(); int getTransparency(); BufferedImage* getSubimage(int x, int y, int w, int h); diff --git a/targets/Minecraft.Client/include/XboxStubs.h b/targets/Minecraft.Client/include/XboxStubs.h index c75559624..aa431167f 100644 --- a/targets/Minecraft.Client/include/XboxStubs.h +++ b/targets/Minecraft.Client/include/XboxStubs.h @@ -68,10 +68,7 @@ public: typedef void* XMEMDECOMPRESSION_CONTEXT; typedef void* XMEMCOMPRESSION_CONTEXT; -enum XMEMCODEC_TYPE { - XMEMCODEC_DEFAULT = 0, - XMEMCODEC_LZX = 1 -}; +enum XMEMCODEC_TYPE { XMEMCODEC_DEFAULT = 0, XMEMCODEC_LZX = 1 }; int32_t XMemDecompress(XMEMDECOMPRESSION_CONTEXT Context, void* pDestination, size_t* pDestSize, void* pSource, size_t SrcSize); diff --git a/targets/Minecraft.Client/src/BufferedImage.cpp b/targets/Minecraft.Client/src/BufferedImage.cpp index 0d612a201..9ccdbd618 100644 --- a/targets/Minecraft.Client/src/BufferedImage.cpp +++ b/targets/Minecraft.Client/src/BufferedImage.cpp @@ -88,7 +88,7 @@ BufferedImage::BufferedImage(const std::wstring& File, } D3DXIMAGE_INFO ImageInfo; - memset(&ImageInfo, 0, sizeof(D3DXIMAGE_INFO)); + memset(&ImageInfo, 0, sizeof(D3DXIMAGE_INFO)); if (foundOnDisk) { hr = RenderManager.LoadTextureData(wstringtofilename(finalPath), @@ -164,7 +164,7 @@ BufferedImage::BufferedImage(std::uint8_t* pbData, std::uint32_t dataBytes) { } D3DXIMAGE_INFO ImageInfo; - memset(&ImageInfo, 0, sizeof(D3DXIMAGE_INFO)); + memset(&ImageInfo, 0, sizeof(D3DXIMAGE_INFO)); int32_t hr = RenderManager.LoadTextureData(pbData, dataBytes, &ImageInfo, &data[0]); @@ -186,8 +186,9 @@ int BufferedImage::getWidth() { return width; } int BufferedImage::getHeight() { return height; } -void BufferedImage::getRGB(int startX, int startY, int w, int h, std::vector& out, - int offset, int scansize, int level) { +void BufferedImage::getRGB(int startX, int startY, int w, int h, + std::vector& out, int offset, int scansize, + int level) { int ww = width >> level; for (int y = 0; y < h; y++) { for (int x = 0; x < w; x++) { @@ -225,13 +226,12 @@ BufferedImage* BufferedImage::getSubimage(int x, int y, int w, int h) { BufferedImage* img = new BufferedImage(w, h, 0); // 4jcraft: Copy pixel data directly into img->data[0]. - // The old arrayWithLength.h (custom vector impl) was a non-owning wrapper, std::vector copies - // so we write to the raw array directly instead. + // The old arrayWithLength.h (custom vector impl) was a non-owning wrapper, + // std::vector copies so we write to the raw array directly instead. int srcW = width; for (int row = 0; row < h; row++) { for (int col = 0; col < w; col++) { - img->data[0][row * w + col] = - data[0][(y + row) * srcW + (x + col)]; + img->data[0][row * w + col] = data[0][(y + row) * srcW + (x + col)]; } } diff --git a/targets/console_helpers/include/console_helpers/PlatformTime.h b/targets/console_helpers/include/console_helpers/PlatformTime.h index b74145e84..8246d38dd 100644 --- a/targets/console_helpers/include/console_helpers/PlatformTime.h +++ b/targets/console_helpers/include/console_helpers/PlatformTime.h @@ -25,14 +25,14 @@ inline std::int64_t QueryPerformanceCounter() { // Ticks per second for the high-resolution counter. inline std::int64_t QueryPerformanceFrequency() { - return static_cast(std::chrono::steady_clock::period::den) - / static_cast(std::chrono::steady_clock::period::num); + return static_cast(std::chrono::steady_clock::period::den) / + static_cast(std::chrono::steady_clock::period::num); } // Elapsed seconds between two counter values. inline double ElapsedSeconds(std::int64_t start, std::int64_t end) { - return static_cast(end - start) - / static_cast(QueryPerformanceFrequency()); + return static_cast(end - start) / + static_cast(QueryPerformanceFrequency()); } } // namespace PlatformTime diff --git a/targets/console_helpers/src/PerformanceTimer.cpp b/targets/console_helpers/src/PerformanceTimer.cpp index 115b7c5ad..f15f20022 100644 --- a/targets/console_helpers/src/PerformanceTimer.cpp +++ b/targets/console_helpers/src/PerformanceTimer.cpp @@ -15,5 +15,5 @@ void PerformanceTimer::PrintElapsedTime(const std::wstring& description) { std::chrono::steady_clock::now() - m_startTime; fprintf(stderr, "TIMER: %ls: Elapsed time %f\n", description.c_str(), - elapsedTime.count()); + elapsedTime.count()); } diff --git a/targets/console_helpers/src/compression.cpp b/targets/console_helpers/src/compression.cpp index d36c13cbf..6903c9eeb 100644 --- a/targets/console_helpers/src/compression.cpp +++ b/targets/console_helpers/src/compression.cpp @@ -64,7 +64,7 @@ int32_t Compression::CompressLZXRLE(void* pDestination, unsigned int* pDestSize, // 0 - 254 - encodes a single byte // 255 followed by 0, 1, 2 - encodes a 1, 2, or 3 255s // 255 followed by 3-255, followed by a byte - encodes a run of n + 1 bytes - do { + do { unsigned char thisOne = *pucIn++; unsigned int count = 1; @@ -89,10 +89,9 @@ int32_t Compression::CompressLZXRLE(void* pDestination, unsigned int* pDestSize, } } while (pucIn != pucEnd); unsigned int rleSize = (unsigned int)(pucOut - rleCompressBuf); - - Compress(pDestination, pDestSize, rleCompressBuf, rleSize); - + Compress(pDestination, pDestSize, rleCompressBuf, rleSize); + // printf("Compressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize); return 0; @@ -114,7 +113,7 @@ int32_t Compression::CompressRLE(void* pDestination, unsigned int* pDestSize, // 255 followed by 0, 1, 2 - encodes a 1, 2, or 3 255s // 255 followed by 3-255, followed by a byte - encodes a run of n + 1 // bytes - do { + do { unsigned char thisOne = *pucIn++; unsigned int count = 1; @@ -139,7 +138,6 @@ int32_t Compression::CompressRLE(void* pDestination, unsigned int* pDestSize, } } while (pucIn != pucEnd); rleSize = (unsigned int)(pucOut - rleCompressBuf); - } // Return diff --git a/targets/java/include/java/Arrays.h b/targets/java/include/java/Arrays.h index eb7d5b937..0ef1b14ef 100644 --- a/targets/java/include/java/Arrays.h +++ b/targets/java/include/java/Arrays.h @@ -8,32 +8,32 @@ class Biome; class Arrays { public: - static void fill(std::vector& arr, unsigned int from, unsigned int to, - double value) { + static void fill(std::vector& arr, unsigned int from, + unsigned int to, double value) { assert(from >= 0); assert(from <= to); assert(to <= arr.size()); std::fill(arr.data() + from, arr.data() + to, value); } - static void fill(std::vector& arr, unsigned int from, unsigned int to, - float value) { + static void fill(std::vector& arr, unsigned int from, + unsigned int to, float value) { assert(from >= 0); assert(from <= to); assert(to <= arr.size()); std::fill(arr.data() + from, arr.data() + to, value); } - static void fill(std::vector& arr, unsigned int from, unsigned int to, - Biome* value) { + static void fill(std::vector& arr, unsigned int from, + unsigned int to, Biome* value) { assert(from >= 0); assert(from <= to); assert(to <= arr.size()); std::fill(arr.data() + from, arr.data() + to, value); } - static void fill(std::vector& arr, unsigned int from, unsigned int to, - uint8_t value) { + static void fill(std::vector& arr, unsigned int from, + unsigned int to, uint8_t value) { assert(from >= 0); assert(from <= to); assert(to <= arr.size()); diff --git a/targets/java/include/java/ByteBuffer.h b/targets/java/include/java/ByteBuffer.h index b940089c7..c4c9be5c1 100644 --- a/targets/java/include/java/ByteBuffer.h +++ b/targets/java/include/java/ByteBuffer.h @@ -4,7 +4,7 @@ #include #include "Buffer.h" -#include "console_helpers/Definitions.h" // 4jcraft TODO +#include "console_helpers/Definitions.h" // 4jcraft TODO class IntBuffer; class FloatBuffer; diff --git a/targets/java/include/java/InputOutputStream/BufferedOutputStream.h b/targets/java/include/java/InputOutputStream/BufferedOutputStream.h index c6075b146..6f1f5d0c3 100644 --- a/targets/java/include/java/InputOutputStream/BufferedOutputStream.h +++ b/targets/java/include/java/InputOutputStream/BufferedOutputStream.h @@ -12,8 +12,8 @@ private: OutputStream* stream; protected: - std::vector buf; // The internal buffer where data is stored. - unsigned int count; // The number of valid bytes in the buffer. + std::vector buf; // The internal buffer where data is stored. + unsigned int count; // The number of valid bytes in the buffer. public: BufferedOutputStream(OutputStream* out, int size); @@ -21,7 +21,8 @@ public: virtual void flush(); virtual void close(); - virtual void write(const std::vector& b, unsigned int offset, unsigned int length); + virtual void write(const std::vector& b, unsigned int offset, + unsigned int length); virtual void write(const std::vector& b); virtual void write(unsigned int b); }; \ No newline at end of file diff --git a/targets/java/include/java/InputOutputStream/ByteArrayInputStream.h b/targets/java/include/java/InputOutputStream/ByteArrayInputStream.h index d796aaeb2..65a6cc38f 100644 --- a/targets/java/include/java/InputOutputStream/ByteArrayInputStream.h +++ b/targets/java/include/java/InputOutputStream/ByteArrayInputStream.h @@ -8,8 +8,8 @@ class ByteArrayInputStream : public InputStream { protected: - std::vector buf; // An array of bytes that was provided by the creator of the - // stream. + std::vector buf; // An array of bytes that was provided by the + // creator of the stream. unsigned int count; // The index one greater than the last valid character // in the input stream buffer. unsigned int mark; // The currently marked position in the stream. @@ -23,7 +23,8 @@ public: virtual ~ByteArrayInputStream(); virtual int read(); virtual int read(std::vector& b); - virtual int read(std::vector& b, unsigned int offset, unsigned int length); + virtual int read(std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual int64_t skip(int64_t n); diff --git a/targets/java/include/java/InputOutputStream/ByteArrayOutputStream.h b/targets/java/include/java/InputOutputStream/ByteArrayOutputStream.h index befa23423..73c291e26 100644 --- a/targets/java/include/java/InputOutputStream/ByteArrayOutputStream.h +++ b/targets/java/include/java/InputOutputStream/ByteArrayOutputStream.h @@ -6,8 +6,8 @@ #include class ByteArrayOutputStream : public OutputStream { - // Note - when actually implementing, std::vector will need to grow as data is - // written + // Note - when actually implementing, std::vector will need to grow + // as data is written public: std::vector buf; // The buffer where data is stored. @@ -22,7 +22,8 @@ public: virtual void flush() {} virtual void write(unsigned int b); virtual void write(const std::vector& b); - virtual void write(const std::vector& b, unsigned int offset, unsigned int length); + virtual void write(const std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual std::vector toByteArray(); diff --git a/targets/java/include/java/InputOutputStream/DataInput.h b/targets/java/include/java/InputOutputStream/DataInput.h index cff082cf8..367da6cbe 100644 --- a/targets/java/include/java/InputOutputStream/DataInput.h +++ b/targets/java/include/java/InputOutputStream/DataInput.h @@ -8,7 +8,8 @@ class DataInput { public: virtual int read() = 0; virtual int read(std::vector& b) = 0; - virtual int read(std::vector& b, unsigned int offset, unsigned int length) = 0; + virtual int read(std::vector& b, unsigned int offset, + unsigned int length) = 0; virtual bool readBoolean() = 0; virtual uint8_t readByte() = 0; virtual unsigned char readUnsignedByte() = 0; diff --git a/targets/java/include/java/InputOutputStream/DataInputStream.h b/targets/java/include/java/InputOutputStream/DataInputStream.h index 90d94313a..a0b01d6fa 100644 --- a/targets/java/include/java/InputOutputStream/DataInputStream.h +++ b/targets/java/include/java/InputOutputStream/DataInputStream.h @@ -16,7 +16,8 @@ public: DataInputStream(InputStream* in); virtual int read(); virtual int read(std::vector& b); - virtual int read(std::vector& b, unsigned int offset, unsigned int length); + virtual int read(std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual bool readBoolean(); virtual uint8_t readByte(); diff --git a/targets/java/include/java/InputOutputStream/DataOutputStream.h b/targets/java/include/java/InputOutputStream/DataOutputStream.h index 72568ca08..1821ad734 100644 --- a/targets/java/include/java/InputOutputStream/DataOutputStream.h +++ b/targets/java/include/java/InputOutputStream/DataOutputStream.h @@ -23,7 +23,8 @@ public: virtual void write(unsigned int b); virtual void write(const std::vector& b); - virtual void write(const std::vector& b, unsigned int offset, unsigned int length); + virtual void write(const std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual void writeByte(uint8_t a); virtual void writeDouble(double a); diff --git a/targets/java/include/java/InputOutputStream/FileInputStream.h b/targets/java/include/java/InputOutputStream/FileInputStream.h index b474044b5..2c084cf0d 100644 --- a/targets/java/include/java/InputOutputStream/FileInputStream.h +++ b/targets/java/include/java/InputOutputStream/FileInputStream.h @@ -14,7 +14,8 @@ public: virtual ~FileInputStream(); virtual int read(); virtual int read(std::vector& b); - virtual int read(std::vector& b, unsigned int offset, unsigned int length); + virtual int read(std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual int64_t skip(int64_t n); diff --git a/targets/java/include/java/InputOutputStream/FileOutputStream.h b/targets/java/include/java/InputOutputStream/FileOutputStream.h index 52b349db0..40f438587 100644 --- a/targets/java/include/java/InputOutputStream/FileOutputStream.h +++ b/targets/java/include/java/InputOutputStream/FileOutputStream.h @@ -13,7 +13,8 @@ public: virtual ~FileOutputStream(); virtual void write(unsigned int b); virtual void write(const std::vector& b); - virtual void write(const std::vector& b, unsigned int offset, unsigned int length); + virtual void write(const std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual void flush(); diff --git a/targets/java/include/java/InputOutputStream/GZIPInputStream.h b/targets/java/include/java/InputOutputStream/GZIPInputStream.h index c1179cafb..6fa590f70 100644 --- a/targets/java/include/java/InputOutputStream/GZIPInputStream.h +++ b/targets/java/include/java/InputOutputStream/GZIPInputStream.h @@ -14,7 +14,8 @@ public: GZIPInputStream(InputStream* out) : stream(out) {}; virtual int read() { return stream->read(); }; virtual int read(std::vector& b) { return stream->read(b); }; - virtual int read(std::vector& b, unsigned int offset, unsigned int length) { + virtual int read(std::vector& b, unsigned int offset, + unsigned int length) { return stream->read(b, offset, length); }; virtual void close() { return stream->close(); }; diff --git a/targets/java/include/java/InputOutputStream/GZIPOutputStream.h b/targets/java/include/java/InputOutputStream/GZIPOutputStream.h index 988475484..b7015ee4f 100644 --- a/targets/java/include/java/InputOutputStream/GZIPOutputStream.h +++ b/targets/java/include/java/InputOutputStream/GZIPOutputStream.h @@ -12,7 +12,8 @@ public: GZIPOutputStream(OutputStream* out) : stream(out) {}; virtual void write(unsigned int b) { stream->write(b); }; virtual void write(const std::vector& b) { stream->write(b); }; - virtual void write(const std::vector& b, unsigned int offset, unsigned int length) { + virtual void write(const std::vector& b, unsigned int offset, + unsigned int length) { stream->write(b, offset, length); }; virtual void close() { stream->close(); }; diff --git a/targets/java/include/java/InputOutputStream/InputStream.h b/targets/java/include/java/InputOutputStream/InputStream.h index ce91ba661..5d67c9854 100644 --- a/targets/java/include/java/InputOutputStream/InputStream.h +++ b/targets/java/include/java/InputOutputStream/InputStream.h @@ -12,7 +12,8 @@ public: virtual int read() = 0; virtual int read(std::vector& b) = 0; - virtual int read(std::vector& b, unsigned int offset, unsigned int length) = 0; + virtual int read(std::vector& b, unsigned int offset, + unsigned int length) = 0; virtual void close() = 0; virtual int64_t skip(int64_t n) = 0; diff --git a/targets/java/include/java/System.h b/targets/java/include/java/System.h index 8f87afef7..8af0e13e2 100644 --- a/targets/java/include/java/System.h +++ b/targets/java/include/java/System.h @@ -10,15 +10,15 @@ class Biome; class Node; // 4J Jev, just thought it would be easier this way. -#define ArrayCopyFunctionDeclaration(x) \ - static void arraycopy(const std::vector& src, unsigned int srcPos, \ - std::vector* dst, unsigned int dstPos, \ +#define ArrayCopyFunctionDeclaration(x) \ + static void arraycopy(const std::vector& src, unsigned int srcPos, \ + std::vector* dst, unsigned int dstPos, \ unsigned int length); -#define ArrayCopyFunctionDefinition(x) \ - void System::arraycopy(const std::vector& src, unsigned int srcPos, \ - std::vector* dst, unsigned int dstPos, \ - unsigned int length) { \ - arraycopy(src, srcPos, dst, dstPos, length); \ +#define ArrayCopyFunctionDefinition(x) \ + void System::arraycopy(const std::vector& src, unsigned int srcPos, \ + std::vector* dst, unsigned int dstPos, \ + unsigned int length) { \ + arraycopy(src, srcPos, dst, dstPos, length); \ } class System { diff --git a/targets/java/src/ByteBuffer.cpp b/targets/java/src/ByteBuffer.cpp index 868de1ec5..0e5ce29af 100644 --- a/targets/java/src/ByteBuffer.cpp +++ b/targets/java/src/ByteBuffer.cpp @@ -393,7 +393,9 @@ ByteBuffer* ByteBuffer::put(std::vector& inputArray) { return this; } -std::vector ByteBuffer::array() { return std::vector(buffer, buffer + m_capacity); } +std::vector ByteBuffer::array() { + return std::vector(buffer, buffer + m_capacity); +} // Creates a view of this byte buffer as an int buffer. // The content of the new buffer will start at this buffer's current position. diff --git a/targets/java/src/File.cpp b/targets/java/src/File.cpp index 7eeede6fb..fea598ad8 100644 --- a/targets/java/src/File.cpp +++ b/targets/java/src/File.cpp @@ -9,8 +9,8 @@ #include "java/FileFilter.h" #include "java/File.h" -#include "console_helpers/PathHelper.h" // 4jcraft TODO -#include "console_helpers/StringHelpers.h" // 4jcraft TODO +#include "console_helpers/PathHelper.h" // 4jcraft TODO +#include "console_helpers/StringHelpers.h" // 4jcraft TODO const wchar_t File::pathSeparator = L'/'; diff --git a/targets/java/src/InputOutputStream/BufferedOutputStream.cpp b/targets/java/src/InputOutputStream/BufferedOutputStream.cpp index fa867d963..84ddd0aec 100644 --- a/targets/java/src/InputOutputStream/BufferedOutputStream.cpp +++ b/targets/java/src/InputOutputStream/BufferedOutputStream.cpp @@ -25,8 +25,8 @@ BufferedOutputStream::~BufferedOutputStream() { void BufferedOutputStream::flush() { if (stream == nullptr) { fprintf(stderr, - "BufferedOutputStream::flush() called but underlying stream is " - "nullptr\n"); + "BufferedOutputStream::flush() called but underlying stream is " + "nullptr\n"); return; } @@ -43,8 +43,8 @@ void BufferedOutputStream::close() { flush(); if (stream == nullptr) { fprintf(stderr, - "BufferedOutputStream::close() called but underlying stream is " - "nullptr\n"); + "BufferedOutputStream::close() called but underlying stream is " + "nullptr\n"); return; } stream->close(); @@ -64,8 +64,8 @@ void BufferedOutputStream::close() { // b - the data. // off - the start offset in the data. // len - the number of bytes to write. -void BufferedOutputStream::write(const std::vector& b, unsigned int offset, - unsigned int length) { +void BufferedOutputStream::write(const std::vector& b, + unsigned int offset, unsigned int length) { // Over the length of what we can store in our buffer - just flush the // buffer and output directly if (length >= buf.size()) { @@ -84,7 +84,9 @@ void BufferedOutputStream::write(const std::vector& b, unsigned int off // // Note that this method does not call the one-argument write method of its // underlying stream with the single argument b. -void BufferedOutputStream::write(const std::vector& b) { write(b, 0, b.size()); } +void BufferedOutputStream::write(const std::vector& b) { + write(b, 0, b.size()); +} // Writes the specified byte to this buffered output stream. // Overrides: diff --git a/targets/java/src/InputOutputStream/ByteArrayInputStream.cpp b/targets/java/src/InputOutputStream/ByteArrayInputStream.cpp index b2b62b3f3..0e7a82056 100644 --- a/targets/java/src/InputOutputStream/ByteArrayInputStream.cpp +++ b/targets/java/src/InputOutputStream/ByteArrayInputStream.cpp @@ -12,9 +12,12 @@ #include "java/InputOutputStream/ByteArrayInputStream.h" -ByteArrayInputStream::ByteArrayInputStream(std::vector& buf, unsigned int offset, +ByteArrayInputStream::ByteArrayInputStream(std::vector& buf, + unsigned int offset, unsigned int length) - : pos(offset), count(std::min(offset + length, (unsigned int)buf.size())), mark(offset) { + : pos(offset), + count(std::min(offset + length, (unsigned int)buf.size())), + mark(offset) { this->buf = buf; } @@ -59,7 +62,9 @@ int ByteArrayInputStream::read() { // Returns: // the total number of bytes read into the buffer, or -1 is there is no more // data because the end of the stream has been reached. -int ByteArrayInputStream::read(std::vector& b) { return read(b, 0, b.size()); } +int ByteArrayInputStream::read(std::vector& b) { + return read(b, 0, b.size()); +} // Reads up to len bytes of data into an array of bytes from this input stream. // If pos equals count, then -1 is returned to indicate end of file. Otherwise, @@ -110,5 +115,4 @@ int64_t ByteArrayInputStream::skip(int64_t n) { return k; } -ByteArrayInputStream::~ByteArrayInputStream() { -} +ByteArrayInputStream::~ByteArrayInputStream() {} diff --git a/targets/java/src/InputOutputStream/ByteArrayOutputStream.cpp b/targets/java/src/InputOutputStream/ByteArrayOutputStream.cpp index 2d5b77c35..b32d280bf 100644 --- a/targets/java/src/InputOutputStream/ByteArrayOutputStream.cpp +++ b/targets/java/src/InputOutputStream/ByteArrayOutputStream.cpp @@ -18,8 +18,7 @@ ByteArrayOutputStream::ByteArrayOutputStream(unsigned int size) { buf = std::vector(size); } -ByteArrayOutputStream::~ByteArrayOutputStream() { -} +ByteArrayOutputStream::~ByteArrayOutputStream() {} // Writes the specified byte to this byte array output stream. // Parameters: @@ -35,18 +34,21 @@ void ByteArrayOutputStream::write(unsigned int b) { // Writes b.size() bytes from the specified byte array to this output stream. // The general contract for write(b) is that it should have exactly the same // effect as the call write(b, 0, b.size()). -void ByteArrayOutputStream::write(const std::vector& b) { write(b, 0, b.size()); } +void ByteArrayOutputStream::write(const std::vector& b) { + write(b, 0, b.size()); +} // Writes len bytes from the specified byte array starting at offset off to this // byte array output stream. Parameters: b - the data. off - the start offset in // the data. len - the number of bytes to write. -void ByteArrayOutputStream::write(const std::vector& b, unsigned int offset, - unsigned int length) { +void ByteArrayOutputStream::write(const std::vector& b, + unsigned int offset, unsigned int length) { assert(b.size() >= offset + length); // If we will fill the buffer we need to make it bigger if (count + length >= buf.size()) - buf.resize(std::max(count + length + 1, (unsigned int)(buf.size() * 2))); + buf.resize( + std::max(count + length + 1, (unsigned int)(buf.size() * 2))); std::memcpy(&buf[count], &b[offset], length); // std::copy( b->data+offset, b->data+offset+length, buf->data + count ); // diff --git a/targets/java/src/InputOutputStream/DataInputStream.cpp b/targets/java/src/InputOutputStream/DataInputStream.cpp index 4060db9b2..af8756f07 100644 --- a/targets/java/src/InputOutputStream/DataInputStream.cpp +++ b/targets/java/src/InputOutputStream/DataInputStream.cpp @@ -21,8 +21,8 @@ DataInputStream::DataInputStream(InputStream* in) : stream(in) {} int DataInputStream::read() { if (stream == nullptr) { fprintf(stderr, - "DataInputStream::read() called but underlying stream is " - "nullptr\n"); + "DataInputStream::read() called but underlying stream is " + "nullptr\n"); return -1; } return stream->read(); @@ -56,8 +56,9 @@ int DataInputStream::read() { int DataInputStream::read(std::vector& b) { if (stream == nullptr) { fprintf(stderr, - "DataInputStream::read(std::vector) called but underlying stream is " - "nullptr\n"); + "DataInputStream::read(std::vector) called but " + "underlying stream is " + "nullptr\n"); return -1; } return read(b, 0, b.size()); @@ -96,8 +97,9 @@ int DataInputStream::read(std::vector& b, unsigned int offset, unsigned int length) { if (stream == nullptr) { fprintf(stderr, - "DataInputStream::read(std::vector,offset,length) called but " - "underlying stream is nullptr\n"); + "DataInputStream::read(std::vector,offset,length) " + "called but " + "underlying stream is nullptr\n"); return -1; } return stream->read(b, offset, length); @@ -108,8 +110,8 @@ int DataInputStream::read(std::vector& b, unsigned int offset, void DataInputStream::close() { if (stream == nullptr) { fprintf(stderr, - "DataInputStream::close() called but underlying stream is " - "nullptr\n"); + "DataInputStream::close() called but underlying stream is " + "nullptr\n"); return; } stream->close(); @@ -121,8 +123,8 @@ void DataInputStream::close() { bool DataInputStream::readBoolean() { if (stream == nullptr) { fprintf(stderr, - "DataInputStream::readBoolean() but underlying stream is " - "nullptr\n"); + "DataInputStream::readBoolean() but underlying stream is " + "nullptr\n"); return false; } return stream->read() != 0; @@ -134,7 +136,8 @@ bool DataInputStream::readBoolean() { // the 8-bit value read. uint8_t DataInputStream::readByte() { if (stream == nullptr) { - fprintf(stderr, + fprintf( + stderr, "DataInputStream::readByte() but underlying stream is nullptr\n"); return 0; } @@ -144,8 +147,8 @@ uint8_t DataInputStream::readByte() { unsigned char DataInputStream::readUnsignedByte() { if (stream == nullptr) { fprintf(stderr, - "DataInputStream::readUnsignedByte() but underlying stream is " - "nullptr\n"); + "DataInputStream::readUnsignedByte() but underlying stream is " + "nullptr\n"); return 0; } return (unsigned char)stream->read(); @@ -159,7 +162,8 @@ unsigned char DataInputStream::readUnsignedByte() { // interface DataOutput. Returns: the char value read. wchar_t DataInputStream::readChar() { if (stream == nullptr) { - fprintf(stderr, + fprintf( + stderr, "DataInputStream::readChar() but underlying stream is nullptr\n"); return 0; } @@ -190,8 +194,9 @@ bool DataInputStream::readFully(std::vector& b) { // InputStreams if (stream == nullptr) { fprintf(stderr, - "DataInputStream::readFully(std::vector) but underlying stream is " - "nullptr\n"); + "DataInputStream::readFully(std::vector) but " + "underlying stream is " + "nullptr\n"); return false; } for (unsigned int i = 0; i < b.size(); i++) { @@ -212,8 +217,9 @@ bool DataInputStream::readFully(std::vector& b) { // InputStreams if (stream == nullptr) { fprintf(stderr, - "DataInputStream::readFully(std::vector) but underlying stream is " - "nullptr\n"); + "DataInputStream::readFully(std::vector) but underlying " + "stream is " + "nullptr\n"); return false; } for (unsigned int i = 0; i < b.size(); i++) { @@ -260,7 +266,8 @@ float DataInputStream::readFloat() { // interface DataOutput. Returns: the int value read. int DataInputStream::readInt() { if (stream == nullptr) { - fprintf(stderr, + fprintf( + stderr, "DataInputStream::readInt() but underlying stream is nullptr\n"); return 0; } @@ -292,7 +299,8 @@ int DataInputStream::readInt() { // the long value read. int64_t DataInputStream::readLong() { if (stream == nullptr) { - fprintf(stderr, + fprintf( + stderr, "DataInputStream::readLong() but underlying stream is nullptr\n"); return 0; } @@ -321,7 +329,8 @@ int64_t DataInputStream::readLong() { // method of interface DataOutput. Returns: the 16-bit value read. short DataInputStream::readShort() { if (stream == nullptr) { - fprintf(stderr, + fprintf( + stderr, "DataInputStream::readShort() but underlying stream is nullptr\n"); return 0; } @@ -333,8 +342,8 @@ short DataInputStream::readShort() { unsigned short DataInputStream::readUnsignedShort() { if (stream == nullptr) { fprintf(stderr, - "DataInputStream::readUnsignedShort() but underlying stream is " - "nullptr\n"); + "DataInputStream::readUnsignedShort() but underlying stream is " + "nullptr\n"); return 0; } int a = stream->read(); @@ -391,7 +400,8 @@ unsigned short DataInputStream::readUnsignedShort() { std::wstring DataInputStream::readUTF() { std::wstring outputString; if (stream == nullptr) { - fprintf(stderr, + fprintf( + stderr, "DataInputStream::readUTF() but underlying stream is nullptr\n"); return outputString; } @@ -519,8 +529,8 @@ int DataInputStream::readUTFChar() { int returnValue = -1; if (stream == nullptr) { fprintf(stderr, - "DataInputStream::readUTFChar() but underlying stream is " - "nullptr\n"); + "DataInputStream::readUTFChar() but underlying stream is " + "nullptr\n"); return returnValue; } int firstByte = stream->read(); diff --git a/targets/java/src/InputOutputStream/DataOutputStream.cpp b/targets/java/src/InputOutputStream/DataOutputStream.cpp index 3b45c5570..2960f2e26 100644 --- a/targets/java/src/InputOutputStream/DataOutputStream.cpp +++ b/targets/java/src/InputOutputStream/DataOutputStream.cpp @@ -25,8 +25,8 @@ void DataOutputStream::deleteChildStream() { delete stream; } void DataOutputStream::write(unsigned int b) { if (stream == nullptr) { fprintf(stderr, - "DataOutputStream::write(unsigned int) called but underlying " - "stream is nullptr\n"); + "DataOutputStream::write(unsigned int) called but underlying " + "stream is nullptr\n"); return; } stream->write(b); @@ -37,8 +37,8 @@ void DataOutputStream::write(unsigned int b) { void DataOutputStream::flush() { if (stream == nullptr) { fprintf(stderr, - "DataOutputStream::flush() called but underlying stream is " - "nullptr\n"); + "DataOutputStream::flush() called but underlying stream is " + "nullptr\n"); return; } stream->flush(); @@ -47,7 +47,9 @@ void DataOutputStream::flush() { // Writes b.size() bytes from the specified byte array to this output stream. // The general contract for write(b) is that it should have exactly the same // effect as the call write(b, 0, b.size()). Parameters: b - the data. -void DataOutputStream::write(const std::vector& b) { write(b, 0, b.size()); } +void DataOutputStream::write(const std::vector& b) { + write(b, 0, b.size()); +} // Writes len bytes from the specified byte array starting at offset off to the // underlying output stream. If no exception is thrown, the counter written is @@ -57,8 +59,9 @@ void DataOutputStream::write(const std::vector& b, unsigned int offset, unsigned int length) { if (stream == nullptr) { fprintf(stderr, - "DataOutputStream::write(std::vector,...) called but underlying " - "stream is nullptr\n"); + "DataOutputStream::write(std::vector,...) called but " + "underlying " + "stream is nullptr\n"); return; } stream->write(b, offset, length); @@ -72,8 +75,8 @@ void DataOutputStream::write(const std::vector& b, unsigned int offset, void DataOutputStream::close() { if (stream == nullptr) { fprintf(stderr, - "DataOutputStream::close() called but underlying stream is " - "nullptr\n"); + "DataOutputStream::close() called but underlying stream is " + "nullptr\n"); return; } stream->close(); @@ -154,7 +157,8 @@ void DataOutputStream::writeShort(short a) { void DataOutputStream::writeUnsignedShort(unsigned short a) { if (stream == nullptr) { - fprintf(stderr, + fprintf( + stderr, "DataOutputStream::writeUnsignedShort() but underlying stream is " "nullptr\n"); return; @@ -258,4 +262,6 @@ void DataOutputStream::writeUTF(const std::wstring& str) { } // 4J Added -void DataOutputStream::writePlayerUID(unsigned long long player) { writeLong(player); } +void DataOutputStream::writePlayerUID(unsigned long long player) { + writeLong(player); +} diff --git a/targets/java/src/InputOutputStream/FileOutputStream.cpp b/targets/java/src/InputOutputStream/FileOutputStream.cpp index 7e6d67063..3d23b5dc0 100644 --- a/targets/java/src/InputOutputStream/FileOutputStream.cpp +++ b/targets/java/src/InputOutputStream/FileOutputStream.cpp @@ -5,7 +5,7 @@ #include "java/File.h" #include "java/InputOutputStream/FileOutputStream.h" -#include "console_helpers/StringHelpers.h" // 4jcraft TODO +#include "console_helpers/StringHelpers.h" // 4jcraft TODO // Creates a file output stream to write to the file represented by the // specified File object. A new FileDescriptor object is created to represent diff --git a/targets/minecraft/client/Minecraft.cpp b/targets/minecraft/client/Minecraft.cpp index e04907f46..471eace5c 100644 --- a/targets/minecraft/client/Minecraft.cpp +++ b/targets/minecraft/client/Minecraft.cpp @@ -1017,8 +1017,7 @@ void Minecraft::run_middle() { // } // 4J-PB - AUTOSAVE TIMER - if the player is the host - if (level != nullptr && - g_NetworkManager.IsHost()) { + if (level != nullptr && g_NetworkManager.IsHost()) { /*if(!bAutosaveTimerSet) { // set the timer @@ -1086,8 +1085,10 @@ void Minecraft::run_middle() { #if !defined(_CONTENT_PACKAGE) { // print the time - auto now_tp = std::chrono::system_clock::now(); - std::time_t now_tt = std::chrono::system_clock::to_time_t(now_tp); + auto now_tp = std::chrono:: + system_clock::now(); + std::time_t now_tt = std::chrono:: + system_clock::to_time_t(now_tp); std::tm utcTime{}; #if defined(_WIN32) gmtime_s(&utcTime, &now_tt); @@ -1577,16 +1578,12 @@ void Minecraft::run_middle() { // if (pause) timer.a = 1; - soundEngine->tick((std::shared_ptr*)localplayers, + soundEngine->tick((std::shared_ptr*)localplayers, timer->a); - - // if (level != nullptr) level->updateLights(); glEnable(GL_TEXTURE_2D); - - // if (!Keyboard::isKeyDown(Keyboard.KEY_F7)) // Display.update(); // 4J - removed @@ -1606,7 +1603,6 @@ void Minecraft::run_middle() { player->m_iScreenSection); gameRenderer->render(timer->a, bFirst); bFirst = false; - if (i == iPrimaryPad) { // check to see if we need to capture a @@ -1694,17 +1690,15 @@ void Minecraft::run_middle() { achievementPopup->render(); - std::this_thread::yield(); // 4jcraft added now that we have + std::this_thread::yield(); // 4jcraft added now that we have // portable thread yield. - // std::this_thread::sleep_for( + // std::this_thread::sleep_for( // std::chrono::milliseconds(0)); // 4J - was // Thread.yield()) - // if (Keyboard::isKeyDown(Keyboard::KEY_F7)) // Display.update(); // 4J - removed condition - Display::update(); - + Display::update(); // checkScreenshot(); // 4J - removed @@ -1980,8 +1974,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { glBindTexture(GL_TEXTURE_2D, textures->loadTexture(TN_TERRAIN)); // L"/terrain.png")); if (bFirst) { - if (!pause) textures->tick(bUpdateTextures); - + if (!pause) textures->tick(bUpdateTextures); } /* @@ -3521,8 +3514,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { level->difficulty = options->difficulty; } - if (!pause) gameRenderer->tick(bFirst); - + if (!pause) gameRenderer->tick(bFirst); // 4J - we want to tick each level once only per frame, and do it when a // player that is actually in that level happens to be active. This is @@ -3535,8 +3527,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { levelsTickedFlags = 0; #if !defined(DISABLE_LEVELTICK_THREAD) - levelTickEventQueue->waitForFinish(); - + levelTickEventQueue->waitForFinish(); + #endif SparseLightStorage::tick(); // 4J added CompressedTileStorage::tick(); // 4J added @@ -3562,8 +3554,8 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // level this frame levelsTickedFlags |= (1 << i); - if (!pause) levelRenderer->tick(); - + if (!pause) levelRenderer->tick(); + // if (!pause && player!=null) { // if (player != null && !level.entities.contains(player)) { // level.addEntity(player); @@ -3572,8 +3564,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { if (levels[i] != nullptr) { if (!pause) { if (levels[i]->skyFlashTime > 0) levels[i]->skyFlashTime--; - levels[i]->tickEntities(); - + levels[i]->tickEntities(); } // optimisation to set the culling off early, in parallel with @@ -3585,19 +3576,17 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) { // app.DebugPrintf("Minecraft::tick spawn settings - // Difficulty = %d",options->difficulty); levels[i]->setSpawnSettings(level->difficulty > 0, true); - #if defined(DISABLE_LEVELTICK_THREAD) +#if defined(DISABLE_LEVELTICK_THREAD) levels[i]->tick(); #else levelTickEventQueue->sendEvent(levels[i]); #endif - } } } if (bFirst) { - if (!pause) particleEngine->tick(); - + if (!pause) particleEngine->tick(); } // 4J Stu - Keep ticking the connections if paused so that they don't diff --git a/targets/minecraft/client/gui/Minimap.cpp b/targets/minecraft/client/gui/Minimap.cpp index 33689a3fd..dab01593f 100644 --- a/targets/minecraft/client/gui/Minimap.cpp +++ b/targets/minecraft/client/gui/Minimap.cpp @@ -252,7 +252,7 @@ void Minimap::render(std::shared_ptr player, Textures* textures, // DCR: Render the players current position here instead if (player != nullptr) { wchar_t playerPosText[32]; - memset(&playerPosText, 0, sizeof(wchar_t) * 32); + memset(&playerPosText, 0, sizeof(wchar_t) * 32); int posx = floor(player->x); int posy = floor(player->y); int posz = floor(player->z); diff --git a/targets/minecraft/client/gui/RepairScreen.h b/targets/minecraft/client/gui/RepairScreen.h index 00485ed4d..abedae8df 100644 --- a/targets/minecraft/client/gui/RepairScreen.h +++ b/targets/minecraft/client/gui/RepairScreen.h @@ -2,7 +2,6 @@ #include - #include "minecraft/client/gui/inventory/AbstractContainerScreen.h" #include "minecraft/world/inventory/AnvilMenu.h" #include "minecraft/world/inventory/net.minecraft.world.inventory.ContainerListener.h" diff --git a/targets/minecraft/client/gui/inventory/BeaconScreen.cpp b/targets/minecraft/client/gui/inventory/BeaconScreen.cpp index 6fe6d0c16..762c2cc97 100644 --- a/targets/minecraft/client/gui/inventory/BeaconScreen.cpp +++ b/targets/minecraft/client/gui/inventory/BeaconScreen.cpp @@ -170,12 +170,12 @@ void BeaconScreen::renderBg(float a) { // Render payment item icons itemRenderer->renderGuiItem( font, minecraft->textures, - std::make_shared(Item::emerald_Id, 1, 0), - xo + 42, yo + 109); + std::make_shared(Item::emerald_Id, 1, 0), xo + 42, + yo + 109); itemRenderer->renderGuiItem( font, minecraft->textures, - std::make_shared(Item::diamond_Id, 1, 0), - xo + 42 + 22, yo + 109); + std::make_shared(Item::diamond_Id, 1, 0), xo + 42 + 22, + yo + 109); itemRenderer->renderGuiItem(font, minecraft->textures, std::shared_ptr( new ItemInstance(Item::goldIngot_Id, 1, 0)), diff --git a/targets/minecraft/client/model/BatModel.cpp b/targets/minecraft/client/model/BatModel.cpp index 10cf3aadd..940e2e952 100644 --- a/targets/minecraft/client/model/BatModel.cpp +++ b/targets/minecraft/client/model/BatModel.cpp @@ -77,9 +77,9 @@ void BatModel::render(std::shared_ptr entity, float time, float r, body->xRot = std::numbers::pi; - rightWing->xRot = -std::numbers::pi * .05f; - rightWing->yRot = -std::numbers::pi * .40f; - rightWingTip->yRot = -std::numbers::pi * .55f; + rightWing->xRot = -std::numbers::pi * .05f; + rightWing->yRot = -std::numbers::pi * .40f; + rightWingTip->yRot = -std::numbers::pi * .55f; leftWing->xRot = rightWing->xRot; leftWing->yRot = -rightWing->yRot; leftWingTip->yRot = -rightWingTip->yRot; diff --git a/targets/minecraft/client/model/HumanoidModel.cpp b/targets/minecraft/client/model/HumanoidModel.cpp index 83b811c2c..f0bc6bcf7 100644 --- a/targets/minecraft/client/model/HumanoidModel.cpp +++ b/targets/minecraft/client/model/HumanoidModel.cpp @@ -223,8 +223,10 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, arm0->zRot = 0.0f; arm1->zRot = 0.0f; } else if (uiBitmaskOverrideAnim & (1 << eAnim_SingleArms)) { - arm0->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; - arm1->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; + arm0->xRot = + (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; + arm1->xRot = + (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; arm0->zRot = 0.0f; arm1->zRot = 0.0f; } @@ -232,12 +234,13 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, // that's up else if ((uiBitmaskOverrideAnim & (1 << eAnim_StatueOfLiberty)) && (holdingRightHand == 0) && (attackTime == 0.0f)) { - arm0->xRot = -std::numbers::pi ; + arm0->xRot = -std::numbers::pi; arm0->zRot = -0.3f; arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f; arm1->zRot = 0.0f; } else { - arm0->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; + arm0->xRot = + (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f; arm0->zRot = 0.0f; arm1->zRot = 0.0f; @@ -310,7 +313,8 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, swing *= swing; swing = 1.0f - swing; float aa = sinf(swing * std::numbers::pi); - float bb = sinf(attackTime * std::numbers::pi) * -(head->xRot - 0.7f) * 0.75f; + float bb = sinf(attackTime * std::numbers::pi) * + -(head->xRot - 0.7f) * 0.75f; arm0->xRot -= aa * 1.2f + bb; // 4J - changed 1.2 -> 1.2f arm0->yRot += body->yRot * 2.0f; @@ -331,11 +335,12 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot, is = is * is * is; is = is * is * is; float iss = 1 - is; - arm0->xRot = -std::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) * - (eating_swing > 0.2 ? 1.0f : 0.0f) * - 2.0f; // This factor is the chomping bit (conditional - // factor is so that he doesn't eat whilst the - // food is being pulled away at the end) + arm0->xRot = + -std::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) * + (eating_swing > 0.2 ? 1.0f : 0.0f) * + 2.0f; // This factor is the chomping bit (conditional + // factor is so that he doesn't eat whilst the + // food is being pulled away at the end) arm0->yRot -= iss * 0.5f; // This factor and the following to the general arm // movement through the life of the swing diff --git a/targets/minecraft/client/model/MinecartModel.cpp b/targets/minecraft/client/model/MinecartModel.cpp index 4e538a04a..2a2c87eb7 100644 --- a/targets/minecraft/client/model/MinecartModel.cpp +++ b/targets/minecraft/client/model/MinecartModel.cpp @@ -41,7 +41,7 @@ MinecartModel::MinecartModel() : Model() { cubes[1]->yRot = std::numbers::pi / 2 * 3; cubes[2]->yRot = std::numbers::pi / 2 * 1; cubes[3]->yRot = std::numbers::pi / 2 * 2; - cubes[5]->xRot = -std::numbers::pi / 2; + cubes[5]->xRot = -std::numbers::pi / 2; // 4J added - compile now to avoid random performance hit first time cubes // are rendered diff --git a/targets/minecraft/client/model/ModelHorse.cpp b/targets/minecraft/client/model/ModelHorse.cpp index 549cbd798..4239c5ed0 100644 --- a/targets/minecraft/client/model/ModelHorse.cpp +++ b/targets/minecraft/client/model/ModelHorse.cpp @@ -544,8 +544,7 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, Leg2B->y = Leg2A->y + - (sinf(r90 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * - 7.f); + (sinf(r90 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * 7.f); Leg2B->z = Leg2A->z + (cosf(r270 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * @@ -576,14 +575,16 @@ void ModelHorse::prepareMobModel(std::shared_ptr mob, float wp, Leg3A->xRot = rlegRot; Leg3B->xRot = - (Leg3A->xRot + std::numbers::pi * std::max(0.0f, (.2f + bobValue * .2f))) * + (Leg3A->xRot + + std::numbers::pi * std::max(0.0f, (.2f + bobValue * .2f))) * standing + (legXRotAnim + std::max(0.0f, legAnim1 * 0.5f * ws)) * iStanding; Leg3C->xRot = Leg3B->xRot; Leg4A->xRot = llegRot; Leg4B->xRot = - (Leg4A->xRot + std::numbers::pi * std::max(0.0f, (.2f - bobValue * .2f))) * + (Leg4A->xRot + + std::numbers::pi * std::max(0.0f, (.2f - bobValue * .2f))) * standing + (-legXRotAnim + std::max(0.0f, -legAnim1 * 0.5f * ws)) * iStanding; Leg4C->xRot = Leg4B->xRot; diff --git a/targets/minecraft/client/model/OcelotModel.cpp b/targets/minecraft/client/model/OcelotModel.cpp index c806fd95d..5b99b8fff 100644 --- a/targets/minecraft/client/model/OcelotModel.cpp +++ b/targets/minecraft/client/model/OcelotModel.cpp @@ -162,19 +162,26 @@ void OcelotModel::setupAnim(float time, float r, float bob, float yRot, backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r; backLegR->xRot = ((float)cosf(time * 0.6662f + 0.3f) * 1.f) * r; frontLegL->xRot = - ((float)cosf(time * 0.6662f + std::numbers::pi + 0.3f) * 1.f) * r; - frontLegR->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; - tail2->xRot = 0.55f * std::numbers::pi + 0.1f * std::numbers::pi * cosf(time) * r; + ((float)cosf(time * 0.6662f + std::numbers::pi + 0.3f) * 1.f) * + r; + frontLegR->xRot = + ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; + tail2->xRot = 0.55f * std::numbers::pi + + 0.1f * std::numbers::pi * cosf(time) * r; } else { backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r; - backLegR->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; - frontLegL->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; + backLegR->xRot = + ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; + frontLegL->xRot = + ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; frontLegR->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r; if (state == WALK_STATE) - tail2->xRot = 0.55f * std::numbers::pi + 0.25f * std::numbers::pi * cosf(time) * r; + tail2->xRot = 0.55f * std::numbers::pi + + 0.25f * std::numbers::pi * cosf(time) * r; else - tail2->xRot = 0.55f * std::numbers::pi + 0.15f * std::numbers::pi * cosf(time) * r; + tail2->xRot = 0.55f * std::numbers::pi + + 0.15f * std::numbers::pi * cosf(time) * r; } } } @@ -226,11 +233,11 @@ void OcelotModel::prepareMobModel(std::shared_ptr mob, float time, tail1->xRot = std::numbers::pi * 0.55f; tail2->xRot = std::numbers::pi * 0.85f; - frontLegL->xRot = frontLegR->xRot = -std::numbers::pi * 0.05f; + frontLegL->xRot = frontLegR->xRot = -std::numbers::pi * 0.05f; frontLegL->y = frontLegR->y = frontLegY + 2; frontLegL->z = frontLegR->z = -7; - backLegL->xRot = backLegR->xRot = -std::numbers::pi * 0.5f; + backLegL->xRot = backLegR->xRot = -std::numbers::pi * 0.5f; backLegL->y = backLegR->y = backLegY + 3; backLegL->z = backLegR->z = backLegZ - 4; state = SITTING_STATE; diff --git a/targets/minecraft/client/model/SilverfishModel.cpp b/targets/minecraft/client/model/SilverfishModel.cpp index d982de35e..ad014f29e 100644 --- a/targets/minecraft/client/model/SilverfishModel.cpp +++ b/targets/minecraft/client/model/SilverfishModel.cpp @@ -73,10 +73,10 @@ void SilverfishModel::setupAnim(float time, float r, float bob, float yRot, std::shared_ptr entity, unsigned int uiBitmaskOverrideAnim) { for (unsigned int i = 0; i < bodyParts.size(); i++) { - bodyParts[i]->yRot = cosf(bob * .9f + i * .15f * std::numbers::pi) * std::numbers::pi * .05f * - (1 + abs((int)i - 2)); - bodyParts[i]->x = - sinf(bob * .9f + i * .15f * std::numbers::pi) * std::numbers::pi * .2f * abs((int)i - 2); + bodyParts[i]->yRot = cosf(bob * .9f + i * .15f * std::numbers::pi) * + std::numbers::pi * .05f * (1 + abs((int)i - 2)); + bodyParts[i]->x = sinf(bob * .9f + i * .15f * std::numbers::pi) * + std::numbers::pi * .2f * abs((int)i - 2); } bodyLayers[0]->yRot = bodyParts[2]->yRot; diff --git a/targets/minecraft/client/model/SpiderModel.cpp b/targets/minecraft/client/model/SpiderModel.cpp index 43c969927..5e74a87c1 100644 --- a/targets/minecraft/client/model/SpiderModel.cpp +++ b/targets/minecraft/client/model/SpiderModel.cpp @@ -120,22 +120,38 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot, leg7->yRot = +ur * 2.0f - ro; float c0 = - -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 0 / 4.0f) * 0.4f) * r; + -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 0 / 4.0f) * + 0.4f) * + r; float c1 = - -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 2 / 4.0f) * 0.4f) * r; + -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 2 / 4.0f) * + 0.4f) * + r; float c2 = - -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 1 / 4.0f) * 0.4f) * r; + -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 1 / 4.0f) * + 0.4f) * + r; float c3 = - -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 3 / 4.0f) * 0.4f) * r; + -((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 3 / 4.0f) * + 0.4f) * + r; float s0 = - std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 0 / 4.0f) * 0.4f) * r; + std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 0 / 4.0f) * + 0.4f) * + r; float s1 = - std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 2 / 4.0f) * 0.4f) * r; + std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 2 / 4.0f) * + 0.4f) * + r; float s2 = - std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 1 / 4.0f) * 0.4f) * r; + std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 1 / 4.0f) * + 0.4f) * + r; float s3 = - std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 3 / 4.0f) * 0.4f) * r; + std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 3 / 4.0f) * + 0.4f) * + r; leg0->yRot += +c0; leg1->yRot += -c0; diff --git a/targets/minecraft/client/model/VillagerModel.cpp b/targets/minecraft/client/model/VillagerModel.cpp index cbe3b1e84..3f2765962 100644 --- a/targets/minecraft/client/model/VillagerModel.cpp +++ b/targets/minecraft/client/model/VillagerModel.cpp @@ -78,7 +78,8 @@ void VillagerModel::setupAnim(float time, float r, float bob, float yRot, arms->xRot = -0.75f; leg0->xRot = ((float)cosf(time * 0.6662f) * 1.4f) * r * 0.5f; - leg1->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r * 0.5f; + leg1->xRot = + ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.4f) * r * 0.5f; leg0->yRot = 0; leg1->yRot = 0; } diff --git a/targets/minecraft/client/model/VillagerZombieModel.cpp b/targets/minecraft/client/model/VillagerZombieModel.cpp index 0660513f9..63ededb3a 100644 --- a/targets/minecraft/client/model/VillagerZombieModel.cpp +++ b/targets/minecraft/client/model/VillagerZombieModel.cpp @@ -43,13 +43,14 @@ void VillagerZombieModel::setupAnim(float time, float r, float bob, float yRot, uiBitmaskOverrideAnim); float attack2 = sinf(attackTime * std::numbers::pi); - float attack = sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi); + float attack = + sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi); arm0->zRot = 0; arm1->zRot = 0; arm0->yRot = -(0.1f - attack2 * 0.6f); arm1->yRot = +(0.1f - attack2 * 0.6f); - arm0->xRot = -std::numbers::pi / 2.0f; - arm1->xRot = -std::numbers::pi / 2.0f; + arm0->xRot = -std::numbers::pi / 2.0f; + arm1->xRot = -std::numbers::pi / 2.0f; arm0->xRot -= attack2 * 1.2f - attack * 0.4f; arm1->xRot -= attack2 * 1.2f - attack * 0.4f; diff --git a/targets/minecraft/client/model/WitchModel.cpp b/targets/minecraft/client/model/WitchModel.cpp index 87b7d4b18..40976d89c 100644 --- a/targets/minecraft/client/model/WitchModel.cpp +++ b/targets/minecraft/client/model/WitchModel.cpp @@ -62,9 +62,11 @@ void WitchModel::setupAnim(float time, float r, float bob, float yRot, nose->translateX = nose->translateY = nose->translateZ = 0; float speed = 0.01f * (entity->entityId % 10); - nose->xRot = (sin(entity->tickCount * speed) * 4.5f) * std::numbers::pi / 180; + nose->xRot = + (sin(entity->tickCount * speed) * 4.5f) * std::numbers::pi / 180; nose->yRot = 0; - nose->zRot = (cos(entity->tickCount * speed) * 2.5f) * std::numbers::pi / 180; + nose->zRot = + (cos(entity->tickCount * speed) * 2.5f) * std::numbers::pi / 180; if (holdingItem) { nose->xRot = -0.9f; diff --git a/targets/minecraft/client/model/WitherBossModel.cpp b/targets/minecraft/client/model/WitherBossModel.cpp index 6a8d819f4..4e1cca8dd 100644 --- a/targets/minecraft/client/model/WitherBossModel.cpp +++ b/targets/minecraft/client/model/WitherBossModel.cpp @@ -73,8 +73,8 @@ void WitherBossModel::prepareMobModel(std::shared_ptr mob, std::dynamic_pointer_cast(mob); for (int i = 1; i < 3; i++) { - heads[i]->yRot = - (boss->getHeadYRot(i - 1) - mob->yBodyRot) / (180 / std::numbers::pi); + heads[i]->yRot = (boss->getHeadYRot(i - 1) - mob->yBodyRot) / + (180 / std::numbers::pi); heads[i]->xRot = boss->getHeadXRot(i - 1) / (180 / std::numbers::pi); } } \ No newline at end of file diff --git a/targets/minecraft/client/model/ZombieModel.cpp b/targets/minecraft/client/model/ZombieModel.cpp index 42ab6eab2..2c87414b9 100644 --- a/targets/minecraft/client/model/ZombieModel.cpp +++ b/targets/minecraft/client/model/ZombieModel.cpp @@ -22,7 +22,8 @@ void ZombieModel::setupAnim(float time, float r, float bob, float yRot, uiBitmaskOverrideAnim); float attack2 = sinf(attackTime * std::numbers::pi); - float attack = sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi); + float attack = + sinf((1 - (1 - attackTime) * (1 - attackTime)) * std::numbers::pi); arm0->zRot = 0; arm1->zRot = 0; arm0->yRot = -(0.1f - attack2 * 0.6f); diff --git a/targets/minecraft/client/model/dragon/DragonModel.cpp b/targets/minecraft/client/model/dragon/DragonModel.cpp index 11ac76a91..6d380e017 100644 --- a/targets/minecraft/client/model/dragon/DragonModel.cpp +++ b/targets/minecraft/client/model/dragon/DragonModel.cpp @@ -135,12 +135,15 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, float rotScale = 1.5f; double startComponents[3]; - std::vector start = std::vector(startComponents, startComponents + 3); + std::vector start = + std::vector(startComponents, startComponents + 3); dragon->getLatencyPos(start, 6, a); double latencyPosAComponents[3], latencyPosBComponents[3]; - std::vector latencyPosA = std::vector(latencyPosAComponents, latencyPosAComponents + 3); - std::vector latencyPosB = std::vector(latencyPosBComponents, latencyPosBComponents + 3); + std::vector latencyPosA = + std::vector(latencyPosAComponents, latencyPosAComponents + 3); + std::vector latencyPosB = + std::vector(latencyPosBComponents, latencyPosBComponents + 3); dragon->getLatencyPos(latencyPosA, 5, a); dragon->getLatencyPos(latencyPosB, 10, a); float rot2 = rotWrap(latencyPosA[0] - latencyPosB[0]); @@ -159,14 +162,16 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, dragon->getLatencyPos(p, 5 - i, a); rr = (float)cosf(i * 0.45f + roff) * 0.15f; - neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) * std::numbers::pi / - 180.0f * rotScale; // 4J replaced "p[0] - start[0] with - // call to getHeadPartYRotDiff + neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) * + std::numbers::pi / 180.0f * + rotScale; // 4J replaced "p[0] - start[0] with + // call to getHeadPartYRotDiff neck->xRot = rr + (float)(dragon->getHeadPartYOffset(i, start, p)) * std::numbers::pi / 180.0f * rotScale * 5.0f; // 4J replaced "p[1] - start[1]" with call // to getHeadPartYOffset - neck->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180.0f * rotScale; + neck->zRot = + -rotWrap(p[0] - rot) * std::numbers::pi / 180.0f * rotScale; neck->y = yy; neck->z = zz; @@ -182,10 +187,11 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, head->x = xx; dragon->getLatencyPos(p, 0, a); head->yRot = - rotWrap(dragon->getHeadPartYRotDiff(6, start, p)) * std::numbers::pi / 180.0f * + rotWrap(dragon->getHeadPartYRotDiff(6, start, p)) * std::numbers::pi / + 180.0f * 1; // 4J replaced "p[0] - start[0] with call to getHeadPartYRotDiff - head->xRot = (float)(dragon->getHeadPartYOffset(6, start, p)) * std::numbers::pi / - 180.0f * rotScale * 5.0f; // 4J Added + head->xRot = (float)(dragon->getHeadPartYOffset(6, start, p)) * + std::numbers::pi / 180.0f * rotScale * 5.0f; // 4J Added head->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180 * 1; head->render(scale, usecompiled); glPushMatrix(); @@ -231,8 +237,10 @@ void DragonModel::render(std::shared_ptr entity, float time, float r, for (int i = 0; i < 12; i++) { dragon->getLatencyPos(p, 12 + i, a); rr += sinf(i * 0.45f + roff) * 0.05f; - neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) * std::numbers::pi / 180; - neck->xRot = rr + (float)(p[1] - start[1]) * std::numbers::pi / 180 * rotScale * 5; + neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) * + std::numbers::pi / 180; + neck->xRot = rr + (float)(p[1] - start[1]) * std::numbers::pi / 180 * + rotScale * 5; neck->zRot = rotWrap(p[0] - rot) * std::numbers::pi / 180 * rotScale; neck->y = yy; neck->z = zz; diff --git a/targets/minecraft/client/multiplayer/ClientConnection.cpp b/targets/minecraft/client/multiplayer/ClientConnection.cpp index 3f0a2658e..8d7a9d338 100644 --- a/targets/minecraft/client/multiplayer/ClientConnection.cpp +++ b/targets/minecraft/client/multiplayer/ClientConnection.cpp @@ -990,7 +990,7 @@ void ClientConnection::handleChunkTilesUpdate( MultiPlayerLevel* dimensionLevel = (MultiPlayerLevel*)minecraft->levels[packet->levelIdx]; if (dimensionLevel) { - LevelChunk* lc = dimensionLevel->getChunk(packet->xc, packet->zc); + LevelChunk* lc = dimensionLevel->getChunk(packet->xc, packet->zc); int xo = packet->xc * 16; int zo = packet->zc * 16; // 4J Stu - Unshare before we make any changes incase the server is @@ -1011,8 +1011,8 @@ void ClientConnection::handleChunkTilesUpdate( // If this is going to actually change a tile, we'll need to unshare int prevTile = lc->getTile(x, y, z); if ((tile != prevTile && !forcedUnshare)) { - dimensionLevel->unshareChunkAt(xo, zo); - + dimensionLevel->unshareChunkAt(xo, zo); + forcedUnshare = true; } @@ -1056,12 +1056,9 @@ void ClientConnection::handleChunkTilesUpdate( dimensionLevel->removeUnusedTileEntitiesInRegion( xo + x, y, zo + z, xo + x + 1, y + 1, zo + z + 1); } - dimensionLevel->shareChunkAt(xo, + dimensionLevel->shareChunkAt(xo, zo); // 4J - added - only shares if chunks // are same on server & client - - - } } @@ -1071,32 +1068,28 @@ void ClientConnection::handleBlockRegionUpdate( MultiPlayerLevel* dimensionLevel = (MultiPlayerLevel*)minecraft->levels[packet->levelIdx]; if (dimensionLevel) { - int y1 = packet->y + packet->ys; if (packet->bIsFullChunk) { y1 = Level::maxBuildHeight; if (packet->buffer.size() > 0) { - LevelChunk::reorderBlocksAndDataToXZY(packet->y, packet->xs, + LevelChunk::reorderBlocksAndDataToXZY(packet->y, packet->xs, packet->ys, packet->zs, &packet->buffer); - } } - dimensionLevel->clearResetRegion(packet->x, packet->y, packet->z, + dimensionLevel->clearResetRegion(packet->x, packet->y, packet->z, packet->x + packet->xs - 1, y1 - 1, packet->z + packet->zs - 1); - - // Only full chunks send lighting information now - added flag to end of + // Only full chunks send lighting information now - added flag to end of // this call dimensionLevel->setBlocksAndData(packet->x, packet->y, packet->z, packet->xs, packet->ys, packet->zs, packet->buffer, packet->bIsFullChunk); - // OutputDebugString("END BRU\n"); - // 4J - remove any tite entities in this region which are associated + // 4J - remove any tite entities in this region which are associated // with a tile that is now no longer a tile entity. Without doing this // we end up with stray tile entities kicking round, which leads to a // bug where chests can't be properly placed again in a location after @@ -1104,18 +1097,15 @@ void ClientConnection::handleBlockRegionUpdate( dimensionLevel->removeUnusedTileEntitiesInRegion( packet->x, packet->y, packet->z, packet->x + packet->xs, y1, packet->z + packet->zs); - // If this is a full packet for a chunk, make sure that the cache now // considers that it has data for this chunk - this is used to determine // whether to bother rendering mobs or not, so we don't have them in // crazy positions before the data is there if (packet->bIsFullChunk) { - dimensionLevel->dataReceivedForChunk(packet->x >> 4, + dimensionLevel->dataReceivedForChunk(packet->x >> 4, packet->z >> 4); - } - } } @@ -1135,7 +1125,6 @@ void ClientConnection::handleTileUpdate( MultiPlayerLevel* dimensionLevel = (MultiPlayerLevel*)minecraft->levels[packet->levelIdx]; if (dimensionLevel) { - if (g_NetworkManager.IsHost()) { // 4J Stu - Unshare before we make any changes incase the server is // already another step ahead of us Fix for #7904 - Gameplay: @@ -1147,8 +1136,7 @@ void ClientConnection::handleTileUpdate( int prevData = dimensionLevel->getData(packet->x, packet->y, packet->z); if (packet->block != prevTile || packet->data != prevData) { - dimensionLevel->unshareChunkAt(packet->x, packet->z); - + dimensionLevel->unshareChunkAt(packet->x, packet->z); } } @@ -1161,11 +1149,9 @@ void ClientConnection::handleTileUpdate( dimensionLevel, packet->x, packet->y, packet->z); } - bool tileWasSet = dimensionLevel->doSetTileAndData( + bool tileWasSet = dimensionLevel->doSetTileAndData( packet->x, packet->y, packet->z, packet->block, packet->data); - - // 4J - remove any tite entities in this region which are associated // with a tile that is now no longer a tile entity. Without doing this // we end up with stray tile entities kicking round, which leads to a @@ -1175,12 +1161,9 @@ void ClientConnection::handleTileUpdate( packet->x, packet->y, packet->z, packet->x + 1, packet->y + 1, packet->z + 1); - dimensionLevel->shareChunkAt( + dimensionLevel->shareChunkAt( packet->x, packet->z); // 4J - added - only shares if chunks are // same on server & client - - - } } @@ -2438,9 +2421,9 @@ void ClientConnection::handleRespawn(std::shared_ptr packet) { void ClientConnection::handleExplosion(std::shared_ptr packet) { if (!packet->m_bKnockbackOnly) { // app.DebugPrintf("Received ExplodePacket with explosion data\n"); - Explosion* e = new Explosion(minecraft->level, nullptr, packet->x, + Explosion* e = new Explosion(minecraft->level, nullptr, packet->x, packet->y, packet->z, packet->r); - + // Fix for #81758 - TCR 006 BAS Non-Interactive Pause: TU9: Performance: // Gameplay: After detonating bunch of TNT, game enters unresponsive // state for couple of seconds. The changes we are making here have been @@ -2453,8 +2436,7 @@ void ClientConnection::handleExplosion(std::shared_ptr packet) { // rather than copying around e->finalizeExplosion(true, &packet->toBlow); mpLevel->enableResetChanges(true); - - + delete e; } else { // app.DebugPrintf("Received ExplodePacket with knockback only data\n"); @@ -2708,8 +2690,8 @@ void ClientConnection::handleContainerAck( } if (menu != nullptr) { if (!packet->accepted) { - send(std::make_shared( - packet->containerId, packet->uid, true)); + send(std::make_shared(packet->containerId, + packet->uid, true)); } } } @@ -2833,9 +2815,8 @@ void ClientConnection::handleContainerClose( void ClientConnection::handleTileEvent( std::shared_ptr packet) { - minecraft->level->tileEvent(packet->x, packet->y, packet->z, packet->tile, + minecraft->level->tileEvent(packet->x, packet->y, packet->z, packet->tile, packet->b0, packet->b1); - } void ClientConnection::handleTileDestruction( @@ -2877,8 +2858,7 @@ void ClientConnection::handleGameEvent( app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", m_userIndex); // This just allows it to be shown - if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != - nullptr) + if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != nullptr) minecraft->localgameModes[InputManager.GetPrimaryPad()] ->getTutorial() ->showTutorialPopup(false); @@ -3446,7 +3426,8 @@ void ClientConnection::checkDeferredEntityLinkPackets(int newEntityId) { bool remove = false; // Only consider recently deferred packets - int tickInterval = PlatformTime::GetTickCount() - deferred->m_recievedTick; + int tickInterval = + PlatformTime::GetTickCount() - deferred->m_recievedTick; if (tickInterval < MAX_ENTITY_LINK_DEFERRAL_INTERVAL) { // Note: we assume it's the destination entity if (deferred->m_packet->destId == newEntityId) { diff --git a/targets/minecraft/client/multiplayer/MultiPlayerChunkCache.cpp b/targets/minecraft/client/multiplayer/MultiPlayerChunkCache.cpp index ccd303502..1c0eebfdb 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerChunkCache.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerChunkCache.cpp @@ -26,8 +26,7 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) { memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE); std::vector emptyBlocks(16 * 16 * Level::maxBuildHeight); - emptyChunk = new EmptyLevelChunk( - level, emptyBlocks, 0, 0); + emptyChunk = new EmptyLevelChunk(level, emptyBlocks, 0, 0); // For normal world dimension, create a chunk that can be used to create the // illusion of infinite water at the edge of the world @@ -63,7 +62,6 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) { waterChunk = new WaterLevelChunk(level, bytes, 0, 0); - if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) { for (int x = 0; x < 16; x++) for (int y = 0; y < 128; y++) diff --git a/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp b/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp index 3f86df5ca..e2b444ead 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerGameMode.cpp @@ -129,21 +129,18 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) { } if (localPlayerMode->isCreative()) { - connection->send( - std::make_shared( - PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); + connection->send(std::make_shared( + PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); creativeDestroyBlock(minecraft, this, x, y, z, face); destroyDelay = 5; } else if (!isDestroying || !sameDestroyTarget(x, y, z)) { if (isDestroying) { - connection->send( - std::make_shared( - PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, - yDestroyBlock, zDestroyBlock, face)); + connection->send(std::make_shared( + PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, + yDestroyBlock, zDestroyBlock, face)); } - connection->send( - std::make_shared( - PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); + connection->send(std::make_shared( + PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); int t = minecraft->level->getTile(x, y, z); if (t > 0 && destroyProgress == 0) Tile::tiles[t]->attack(minecraft->level, x, y, z, @@ -172,10 +169,9 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) { void MultiPlayerGameMode::stopDestroyBlock() { if (isDestroying) { - connection->send( - std::make_shared( - PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, - yDestroyBlock, zDestroyBlock, -1)); + connection->send(std::make_shared( + PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, + yDestroyBlock, zDestroyBlock, -1)); } isDestroying = false; @@ -199,9 +195,8 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) { if (localPlayerMode->isCreative()) { destroyDelay = 5; - connection->send( - std::make_shared( - PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); + connection->send(std::make_shared( + PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face)); creativeDestroyBlock(minecraft, this, x, y, z, face); return; } @@ -232,9 +227,8 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) { if (destroyProgress >= 1) { isDestroying = false; - connection->send( - std::make_shared( - PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face)); + connection->send(std::make_shared( + PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face)); destroyBlock(x, y, z, face); destroyProgress = 0; destroyTicks = 0; @@ -533,6 +527,5 @@ bool MultiPlayerGameMode::handleCraftItem(int recipe, void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal, std::shared_ptr player) { player->SetDebugOptions(uiVal); - connection->send( - std::make_shared(uiVal)); + connection->send(std::make_shared(uiVal)); } diff --git a/targets/minecraft/client/multiplayer/MultiPlayerLevel.cpp b/targets/minecraft/client/multiplayer/MultiPlayerLevel.cpp index 7faf7358d..d265b6879 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerLevel.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerLevel.cpp @@ -55,8 +55,8 @@ MultiPlayerLevel::ResetInfo::ResetInfo(int x, int y, int z, int tile, MultiPlayerLevel::MultiPlayerLevel(ClientConnection* connection, LevelSettings* levelSettings, int dimension, int difficulty) - : Level(std::make_shared(), - L"MpServer", Dimension::getNew(dimension), levelSettings, false) { + : Level(std::make_shared(), L"MpServer", + Dimension::getNew(dimension), levelSettings, false) { minecraft = Minecraft::GetInstance(); // 4J - this this used to be called in parent ctor via a virtual fn @@ -116,7 +116,7 @@ void MultiPlayerLevel::shareChunkAt(int x, int z) { } void MultiPlayerLevel::tick() { - setGameTime(getGameTime() + 1); + setGameTime(getGameTime() + 1); if (getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) { // 4J: Debug setting added to keep it at day time #if !defined(_FINAL_BUILD) @@ -140,9 +140,8 @@ void MultiPlayerLevel::tick() { listeners[i]->skyColorChanged(); } }*/ - - { + { std::lock_guard lock(m_entitiesCS); for (int i = 0; i < 10 && !reEntries.empty(); i++) { std::shared_ptr e = *(reEntries.begin()); @@ -151,18 +150,16 @@ void MultiPlayerLevel::tick() { addEntity(e); } } - - // 4J HEG - Copy the connections vector to prevent crash when moving to + // 4J HEG - Copy the connections vector to prevent crash when moving to // Nether std::vector connectionsTemp = connections; for (auto connection = connectionsTemp.begin(); connection < connectionsTemp.end(); ++connection) { (*connection)->tick(); } - - unsigned int lastIndexToRemove = 0; + unsigned int lastIndexToRemove = 0; bool eraseElements = false; for (unsigned int i = 0; i < updatesToReset.size(); i++) { ResetInfo& r = updatesToReset[i]; @@ -185,7 +182,6 @@ void MultiPlayerLevel::tick() { updatesToReset.erase(updatesToReset.begin(), updatesToReset.begin() + lastIndexToRemove); } - chunkCache->tick(); tickTiles(); @@ -409,10 +405,9 @@ void MultiPlayerLevel::tickTiles() { // resets in buildAndPrepareChunksToPoll rather than // the calling functions - Level::tickTiles(); - + Level::tickTiles(); - auto itEndCtp = chunksToPoll.end(); + auto itEndCtp = chunksToPoll.end(); for (auto it = chunksToPoll.begin(); it != itEndCtp; it++) { ChunkPos cp = *it; int xo = cp.x * 16; @@ -422,8 +417,6 @@ void MultiPlayerLevel::tickTiles() { tickClientSideTiles(xo, zo, lc); } - - } void MultiPlayerLevel::setChunkVisible(int x, int z, bool visible) { @@ -912,10 +905,9 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection* c, } void MultiPlayerLevel::tickAllConnections() { - for (auto it = connections.begin(); it < connections.end(); ++it) { + for (auto it = connections.begin(); it < connections.end(); ++it) { (*it)->tick(); } - } void MultiPlayerLevel::dataReceivedForChunk(int x, int z) { diff --git a/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp b/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp index 6a342d2a5..929e1c296 100644 --- a/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp +++ b/targets/minecraft/client/multiplayer/MultiPlayerLocalPlayer.cpp @@ -99,12 +99,10 @@ void MultiplayerLocalPlayer::tick() { if (minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition( tempX, tempY, tempZ, x, y, z)) { if (isRiding()) { - connection->send( - std::make_shared( - yRot, xRot, onGround, abilities.flying)); - connection->send( - std::make_shared( - xxa, yya, input->jumping, input->sneaking)); + connection->send(std::make_shared( + yRot, xRot, onGround, abilities.flying)); + connection->send(std::make_shared( + xxa, yya, input->jumping, input->sneaking)); } else { sendPosition(); } @@ -119,13 +117,11 @@ void MultiplayerLocalPlayer::sendPosition() { bool sprinting = isSprinting(); if (sprinting != lastSprinting) { if (sprinting) - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::START_SPRINTING)); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::START_SPRINTING)); else - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::STOP_SPRINTING)); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::STOP_SPRINTING)); lastSprinting = sprinting; } @@ -133,13 +129,11 @@ void MultiplayerLocalPlayer::sendPosition() { bool sneaking = isSneaking(); if (sneaking != lastSneaked) { if (sneaking) - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::START_SNEAKING)); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::START_SNEAKING)); else - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::STOP_SNEAKING)); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::STOP_SNEAKING)); lastSneaked = sneaking; } @@ -147,13 +141,11 @@ void MultiplayerLocalPlayer::sendPosition() { bool idle = isIdle(); if (idle != lastIdle) { if (idle) - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::START_IDLEANIM)); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::START_IDLEANIM)); else - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM)); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM)); lastIdle = idle; } @@ -169,23 +161,19 @@ void MultiplayerLocalPlayer::sendPosition() { positionReminder >= POSITION_REMINDER_INTERVAL; bool rot = rydd != 0 || rxdd != 0; if (riding != nullptr) { - connection->send( - std::make_shared( - xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying)); + connection->send(std::make_shared( + xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying)); move = false; } else { if (move && rot) { - connection->send( - std::make_shared( - x, bb.y0, y, z, yRot, xRot, onGround, abilities.flying)); + connection->send(std::make_shared( + x, bb.y0, y, z, yRot, xRot, onGround, abilities.flying)); } else if (move) { - connection->send( - std::make_shared( - x, bb.y0, y, z, onGround, abilities.flying)); + connection->send(std::make_shared( + x, bb.y0, y, z, onGround, abilities.flying)); } else if (rot) { - connection->send( - std::make_shared( - yRot, xRot, onGround, abilities.flying)); + connection->send(std::make_shared( + yRot, xRot, onGround, abilities.flying)); } else { connection->send(std::shared_ptr( new MovePlayerPacket(onGround, abilities.flying))); @@ -295,8 +283,7 @@ void MultiplayerLocalPlayer::clientSideCloseContainer() { LocalPlayer::closeContainer(); } -void MultiplayerLocalPlayer::hurtTo(float newHealth, - uint8_t damageSource) { +void MultiplayerLocalPlayer::hurtTo(float newHealth, uint8_t damageSource) { if (flashOnSetHealth) { LocalPlayer::hurtTo(newHealth, damageSource); } else { @@ -305,7 +292,8 @@ void MultiplayerLocalPlayer::hurtTo(float newHealth, } } -void MultiplayerLocalPlayer::awardStat(Stat* stat, const std::vector& param) { +void MultiplayerLocalPlayer::awardStat(Stat* stat, + const std::vector& param) { if (stat == nullptr) { return; } @@ -317,7 +305,8 @@ void MultiplayerLocalPlayer::awardStat(Stat* stat, const std::vector& p } } -void MultiplayerLocalPlayer::awardStatFromServer(Stat* stat, std::vector& param) { +void MultiplayerLocalPlayer::awardStatFromServer(Stat* stat, + std::vector& param) { if (stat != nullptr && !stat->awardLocallyOnly) { LocalPlayer::awardStat(stat, param); } @@ -331,16 +320,14 @@ void MultiplayerLocalPlayer::onUpdateAbilities() { bool MultiplayerLocalPlayer::isLocalPlayer() { return true; } void MultiplayerLocalPlayer::sendRidingJump() { - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::RIDING_JUMP, - (int)(getJumpRidingScale() * 100.0f))); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::RIDING_JUMP, + (int)(getJumpRidingScale() * 100.0f))); } void MultiplayerLocalPlayer::sendOpenInventory() { - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY)); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY)); } void MultiplayerLocalPlayer::ride(std::shared_ptr e) { @@ -371,9 +358,8 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr e) { } void MultiplayerLocalPlayer::StopSleeping() { - connection->send( - std::make_shared( - shared_from_this(), PlayerCommandPacket::STOP_SLEEPING)); + connection->send(std::make_shared( + shared_from_this(), PlayerCommandPacket::STOP_SLEEPING)); } // 4J Added @@ -398,10 +384,9 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) { customTextureUrl2.c_str()); #endif if (getCustomCape() != oldCapeIndex) - connection->send( - std::make_shared( - shared_from_this(), TextureChangePacket::e_TextureChange_Cape, - app.GetPlayerCapeName(GetXboxPad()))); + connection->send(std::make_shared( + shared_from_this(), TextureChangePacket::e_TextureChange_Cape, + app.GetPlayerCapeName(GetXboxPad()))); } // 4J added for testing. This moves the player in a repeated sequence of 2 diff --git a/targets/minecraft/client/multiplayer/ReceivingLevelScreen.cpp b/targets/minecraft/client/multiplayer/ReceivingLevelScreen.cpp index d158c1ceb..b1fadfed4 100644 --- a/targets/minecraft/client/multiplayer/ReceivingLevelScreen.cpp +++ b/targets/minecraft/client/multiplayer/ReceivingLevelScreen.cpp @@ -20,8 +20,7 @@ void ReceivingLevelScreen::init() { buttons.clear(); } void ReceivingLevelScreen::tick() { tickCount++; if (tickCount % 20 == 0) { - connection->send( - std::make_shared()); + connection->send(std::make_shared()); } if (connection != nullptr) { connection->tick(); diff --git a/targets/minecraft/client/particle/FireworksParticles.cpp b/targets/minecraft/client/particle/FireworksParticles.cpp index 63ae1d094..16ca0415b 100644 --- a/targets/minecraft/client/particle/FireworksParticles.cpp +++ b/targets/minecraft/client/particle/FireworksParticles.cpp @@ -104,7 +104,8 @@ void FireworksParticles::FireworksStarter::tick() { int type = compoundTag->getByte(FireworksItem::TAG_E_TYPE); bool trail = compoundTag->getBoolean(FireworksItem::TAG_E_TRAIL); bool flicker = compoundTag->getBoolean(FireworksItem::TAG_E_FLICKER); - std::vector colors = compoundTag->getIntArray(FireworksItem::TAG_E_COLORS); + std::vector colors = + compoundTag->getIntArray(FireworksItem::TAG_E_COLORS); std::vector fadeColors = compoundTag->getIntArray(FireworksItem::TAG_E_FADECOLORS); @@ -120,7 +121,8 @@ void FireworksParticles::FireworksStarter::tick() { 150.0 / 245.0, -197.0 / 245.0, 0.0, -88.0 / 245.0, }; - std::vector> coordsArray(6, std::vector(2)); + std::vector> coordsArray( + 6, std::vector(2)); for (unsigned int i = 0; i < coordsArray.size(); ++i) { for (unsigned int j = 0; j < coordsArray[i].size(); ++j) { coordsArray[i][j] = coords[i][j]; @@ -137,7 +139,8 @@ void FireworksParticles::FireworksStarter::tick() { 0.0, 0.2, 0.2, 0.2, 0.2, 0.6, 0.6, 0.6, 0.6, 0.2, 0.2, 0.2, 0.2, 0.0, 0.4, 0.0, 0.4, -0.6, 0.2, -0.6, 0.2, -0.4, 0.0, -0.4, }; - std::vector> coordsArray(12, std::vector(2)); + std::vector> coordsArray( + 12, std::vector(2)); for (unsigned int i = 0; i < coordsArray.size(); ++i) { for (unsigned int j = 0; j < coordsArray[i].size(); ++j) { coordsArray[i][j] = coords[i][j]; @@ -195,7 +198,8 @@ bool FireworksParticles::FireworksStarter::isFarAwayFromCamera() { void FireworksParticles::FireworksStarter::createParticle( double x, double y, double z, double xa, double ya, double za, - const std::vector& rgbColors, const std::vector& fadeColors, bool trail, bool flicker) { + const std::vector& rgbColors, const std::vector& fadeColors, + bool trail, bool flicker) { std::shared_ptr fireworksSparkParticle = std::shared_ptr( new FireworksSparkParticle(level, x, y, z, xa, ya, za, engine)); @@ -213,8 +217,8 @@ void FireworksParticles::FireworksStarter::createParticle( } void FireworksParticles::FireworksStarter::createParticleBall( - double baseSpeed, int steps, const std::vector& rgbColors, const std::vector& fadeColors, - bool trail, bool flicker) { + double baseSpeed, int steps, const std::vector& rgbColors, + const std::vector& fadeColors, bool trail, bool flicker) { double xx = x; double yy = y; double zz = z; @@ -244,8 +248,9 @@ void FireworksParticles::FireworksStarter::createParticleBall( } void FireworksParticles::FireworksStarter::createParticleShape( - double baseSpeed, std::vector> coords, const std::vector& rgbColors, - const std::vector& fadeColors, bool trail, bool flicker, bool flat) { + double baseSpeed, std::vector> coords, + const std::vector& rgbColors, const std::vector& fadeColors, + bool trail, bool flicker, bool flat) { double sx = coords[0][0]; double sy = coords[0][1]; @@ -285,7 +290,8 @@ void FireworksParticles::FireworksStarter::createParticleShape( } void FireworksParticles::FireworksStarter::createParticleBurst( - const std::vector& rgbColors, const std::vector& fadeColors, bool trail, bool flicker) { + const std::vector& rgbColors, const std::vector& fadeColors, + bool trail, bool flicker) { double baseOffX = random->nextGaussian() * .05; double baseOffZ = random->nextGaussian() * .05; diff --git a/targets/minecraft/client/particle/FireworksParticles.h b/targets/minecraft/client/particle/FireworksParticles.h index 89ccf0b81..d9770250f 100644 --- a/targets/minecraft/client/particle/FireworksParticles.h +++ b/targets/minecraft/client/particle/FireworksParticles.h @@ -8,7 +8,8 @@ class ParticleEngine; class CompoundTag; class Level; -template class ListTag; +template +class ListTag; class FireworksParticles { public: @@ -31,15 +32,21 @@ public: virtual void tick(); bool isFarAwayFromCamera(); void createParticle(double x, double y, double z, double xa, double ya, - double za, const std::vector& rgbColors, const std::vector& fadeColors, - bool trail, bool flicker); - void createParticleBall(double baseSpeed, int steps, const std::vector& rgbColors, - const std::vector& fadeColors, bool trail, bool flicker); - void createParticleShape(double baseSpeed, std::vector> coords, - const std::vector& rgbColors, const std::vector& fadeColors, - bool trail, bool flicker, bool flat); - void createParticleBurst(const std::vector& rgbColors, const std::vector& fadeColors, - bool trail, bool flicker); + double za, const std::vector& rgbColors, + const std::vector& fadeColors, bool trail, + bool flicker); + void createParticleBall(double baseSpeed, int steps, + const std::vector& rgbColors, + const std::vector& fadeColors, bool trail, + bool flicker); + void createParticleShape(double baseSpeed, + std::vector> coords, + const std::vector& rgbColors, + const std::vector& fadeColors, bool trail, + bool flicker, bool flat); + void createParticleBurst(const std::vector& rgbColors, + const std::vector& fadeColors, bool trail, + bool flicker); public: int getParticleTexture(); diff --git a/targets/minecraft/client/particle/NoteParticle.cpp b/targets/minecraft/client/particle/NoteParticle.cpp index 75867f317..7aba37e37 100644 --- a/targets/minecraft/client/particle/NoteParticle.cpp +++ b/targets/minecraft/client/particle/NoteParticle.cpp @@ -24,9 +24,10 @@ gMin = ( (cMin>>8)&0xFF )/255.0, bMin = ( cMin&0xFF )/255.0; double rMax = ( (cMax>>16)&0xFF )/255.0f, gMax = ( (cMax>>8)&0xFF )/255.0, bMax = ( cMax&0xFF )/255.0; -rCol = sinf(((float) xa + 0.0f / 3) * std::numbers::pi * 2) * (rMax - rMin) + rMin; -gCol = sinf(((float) xa + 1.0f / 3) * std::numbers::pi * 2) * (gMax - gMin) + gMin; -bCol = sinf(((float) xa + 2.0f / 3) * std::numbers::pi * 2) * (bMax - bMin) + bMin; +rCol = sinf(((float) xa + 0.0f / 3) * std::numbers::pi * 2) * (rMax - rMin) + +rMin; gCol = sinf(((float) xa + 1.0f / 3) * std::numbers::pi * 2) * (gMax - +gMin) + gMin; bCol = sinf(((float) xa + 2.0f / 3) * std::numbers::pi * 2) * +(bMax - bMin) + bMin; */ // 4J-JEV: Added, diff --git a/targets/minecraft/client/player/Input.cpp b/targets/minecraft/client/player/Input.cpp index 97cc844de..5ba9a83c1 100644 --- a/targets/minecraft/client/player/Input.cpp +++ b/targets/minecraft/client/player/Input.cpp @@ -113,7 +113,8 @@ void Input::tick(LocalPlayer* player) { } tx = ty = 0.0f; } - player->interpolateTurn(tx * std::abs(tx) * turnSpeed, ty * std::abs(ty) * turnSpeed); + player->interpolateTurn(tx * std::abs(tx) * turnSpeed, + ty * std::abs(ty) * turnSpeed); // jumping = controller.isButtonPressed(0); diff --git a/targets/minecraft/client/player/LocalPlayer.cpp b/targets/minecraft/client/player/LocalPlayer.cpp index 6197f799d..49c33bffb 100644 --- a/targets/minecraft/client/player/LocalPlayer.cpp +++ b/targets/minecraft/client/player/LocalPlayer.cpp @@ -154,7 +154,8 @@ void LocalPlayer::serverAiStep() { // Don't bother for tiny inputs if (fMag >= 0.1f) { // Get angle (in player rotated space) of input controls - float yRotInput = atan2f(input->ya, input->xa) * (180.0f / std::numbers::pi); + float yRotInput = + atan2f(input->ya, input->xa) * (180.0f / std::numbers::pi); // Now get in world space float yRotFinal = yRotInput + yRot; // Snap this to nearest 90 degrees @@ -165,8 +166,10 @@ void LocalPlayer::serverAiStep() { float yRotInputAdjust = yRotInput + yRotDiff; // Calculate final x/y player-space movement required - this->xxa = cos(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag; - this->yya = sin(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag; + this->xxa = + cos(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag; + this->yya = + sin(yRotInputAdjust * (std::numbers::pi / 180.0f)) * fMag; } else { this->xxa = input->xa; this->yya = input->ya; @@ -748,9 +751,8 @@ void LocalPlayer::magicCrit(std::shared_ptr e) { } void LocalPlayer::take(std::shared_ptr e, int orgCount) { - minecraft->particleEngine->add( - std::make_shared( - (Level*)minecraft->level, e, shared_from_this(), -0.5f)); + minecraft->particleEngine->add(std::make_shared( + (Level*)minecraft->level, e, shared_from_this(), -0.5f)); } void LocalPlayer::chat(const std::wstring& message) {} @@ -822,7 +824,6 @@ void LocalPlayer::awardStat(Stat* stat, const std::vector& param) { // players cannot get theme/avatar/gamerpic and Trial players cannot // get any This causes some extreme flooding of some awards if (ProfileManager.CanBeAwarded(m_iPad, ach->getAchievementID())) { - // 4J Stu - Some awards cause a menu to popup. This can be bad, // especially if you are surrounded by mobs! We cannot pause the // game unless in offline single player, but lets at least do it diff --git a/targets/minecraft/client/renderer/Chunk.cpp b/targets/minecraft/client/renderer/Chunk.cpp index 583ed92dd..41162f1a7 100644 --- a/targets/minecraft/client/renderer/Chunk.cpp +++ b/targets/minecraft/client/renderer/Chunk.cpp @@ -222,9 +222,8 @@ void Chunk::makeCopyForRebuild(Chunk* source) { } void Chunk::rebuild() { - // if (!dirty) return; - + #if defined(_LARGE_WORLDS) Tesselator* t = Tesselator::getInstance(); #else @@ -257,9 +256,7 @@ void Chunk::rebuild() { 2; lists += levelRenderer->chunkLists; - - - //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // 4J - optimisation begins. // Get the data for the level chunk that this render chunk is it (level @@ -275,9 +272,12 @@ void Chunk::rebuild() { #endif std::vector tileArray(16 * 16 * Level::maxBuildHeight); level->getChunkAt(x, z)->getBlockData(tileArray); - memcpy(tileIds, tileArray.data(), 16 * 16 * Level::maxBuildHeight); // 4J - TODO - now our data has been re-arranged, we could - // just extra the vertical slice of this chunk rather than - // the whole thing + memcpy( + tileIds, tileArray.data(), + 16 * 16 * Level::maxBuildHeight); // 4J - TODO - now our data has been + // re-arranged, we could just extra + // the vertical slice of this chunk + // rather than the whole thing LevelSource* region = new Region(level, x0 - r, y0 - r, z0 - r, x1 + r, y1 + r, z1 + r, r); @@ -404,7 +404,7 @@ void Chunk::rebuild() { } } } - + // Nothing at all to do for this chunk? if (empty) { // 4J - added - clear any renderer data associated with this @@ -428,7 +428,7 @@ void Chunk::rebuild() { // 4J - optimisation ends //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - Tesselator::Bounds bounds; // 4J MGH - added + Tesselator::Bounds bounds; // 4J MGH - added { // this was the old default clip bounds for the chunk, set in // Chunk::setPos. @@ -546,8 +546,6 @@ void Chunk::rebuild() { delete tileRenderer; delete region; - - // 4J - have rewritten the way that tile entities are stored globally to // make it work more easily with split screen. Chunks are now stored // globally in the levelrenderer, in a hashmap with a special key made up @@ -557,7 +555,6 @@ void Chunk::rebuild() { std::lock_guard lock(*globalRenderableTileEntities_cs); reconcileRenderableTileEntities(renderableTileEntities); } - // 4J - These removed items are now also removed from // globalRenderableTileEntities @@ -571,7 +568,7 @@ void Chunk::rebuild() { } levelRenderer->setGlobalChunkFlag(x, y, z, level, LevelRenderer::CHUNK_FLAG_COMPILED); - + return; } diff --git a/targets/minecraft/client/renderer/EntityTileRenderer.cpp b/targets/minecraft/client/renderer/EntityTileRenderer.cpp index 26562c7c2..ea378edb5 100644 --- a/targets/minecraft/client/renderer/EntityTileRenderer.cpp +++ b/targets/minecraft/client/renderer/EntityTileRenderer.cpp @@ -11,8 +11,7 @@ EntityTileRenderer::EntityTileRenderer() { chest = std::make_shared(); trappedChest = std::shared_ptr( new ChestTileEntity(ChestTile::TYPE_TRAP)); - enderChest = - std::make_shared(); + enderChest = std::make_shared(); } void EntityTileRenderer::render(Tile* tile, int data, float brightness, diff --git a/targets/minecraft/client/renderer/GameRenderer.cpp b/targets/minecraft/client/renderer/GameRenderer.cpp index cc5d45434..4a6b2e584 100644 --- a/targets/minecraft/client/renderer/GameRenderer.cpp +++ b/targets/minecraft/client/renderer/GameRenderer.cpp @@ -254,8 +254,7 @@ void GameRenderer::tick(bool first) // 4J - add bFirst itemInHandRenderer->tick(); - tickRain(); - + tickRain(); darkenWorldAmountO = darkenWorldAmount; if (BossMobGuiInfo::darkenWorld) { @@ -459,7 +458,8 @@ void GameRenderer::bobView(float a) { glTranslatef((float)sinf(b * std::numbers::pi) * bob * 0.5f, -(float)std::abs(cosf(b * std::numbers::pi) * bob), 0); glRotatef((float)sinf(b * std::numbers::pi) * bob * 3, 0, 0, 1); - glRotatef((float)std::abs(cosf(b * std::numbers::pi - 0.2f) * bob) * 5, 1, 0, 0); + glRotatef((float)std::abs(cosf(b * std::numbers::pi - 0.2f) * bob) * 5, 1, + 0, 0); glRotatef((float)tilt, 1, 0, 0); } @@ -530,10 +530,10 @@ void GameRenderer::moveCameraToPlayer(float a) { xRot += 180.0f; } - double xd = -sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi) * - cameraDist; - double zd = cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi) * - cameraDist; + double xd = -sinf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi) * cameraDist; + double zd = cosf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi) * cameraDist; double yd = -sinf(xRot / 180 * std::numbers::pi) * cameraDist; for (int i = 0; i < 8; i++) { @@ -768,8 +768,8 @@ void GameRenderer::renderItemInHand(float a, int eye) { !mc->cameraTargetPlayer->isSleeping()) { if (!mc->options->hideGui && !mc->gameMode->isCutScene()) { turnOnLightLayer(a, true); - itemInHandRenderer->render(a); - + itemInHandRenderer->render(a); + turnOffLightLayer(a); } } @@ -1165,7 +1165,7 @@ int GameRenderer::runUpdate(void* lpParam) { m_deleteStackSparseDataStorage.clear(); } - // + // m_updateEvents->set(eUpdateEventIsFinished); } @@ -1278,7 +1278,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { GL11::glShadeModel(GL11::GL_SMOOTH); } - // Culler *frustum = new FrustumCuller(); + // Culler *frustum = new FrustumCuller(); FrustumCuller frustObj; Culler* frustum = &frustObj; frustum->prepare(xOff, yOff, zOff); @@ -1287,16 +1287,15 @@ void GameRenderer::renderLevel(float a, int64_t until) { FRAME_PROFILE_SCOPE(ChunkCull); mc->levelRenderer->cull(frustum, a); } - #if !defined(MULTITHREAD_ENABLE) if ((i == 0) && updateChunks) // 4J - added updateChunks condition { int PIXPass = 0; - do { + do { bool retval = mc->levelRenderer->updateDirtyChunks(cameraEntity, false); - + if (retval) break; if (until == 0) break; @@ -1305,7 +1304,6 @@ void GameRenderer::renderLevel(float a, int64_t until) { if (diff < 0) break; if (diff > 1000000000) break; } while (true); - } #endif @@ -1323,14 +1321,13 @@ void GameRenderer::renderLevel(float a, int64_t until) { mc->textures->bindTexture( &TextureAtlas::LOCATION_BLOCKS); // 4J was L"/terrain.png" Lighting::turnOff(); - levelRenderer->render(cameraEntity, 0, a, updateChunks); - + levelRenderer->render(cameraEntity, 0, a, updateChunks); GL11::glShadeModel(GL11::GL_FLAT); if (cameraFlip == 0) { Lighting::turnOn(); - // 4J - for entities, don't include the "a" factor that interpolates + // 4J - for entities, don't include the "a" factor that interpolates // from the old to new position, as the AABBs for the entities are // already fully at the new position This fixes flickering // minecarts, and pigs that you are riding on @@ -1349,8 +1346,8 @@ void GameRenderer::renderLevel(float a, int64_t until) { FRAME_PROFILE_SCOPE(Entity); levelRenderer->renderEntities(&cameraPos, frustum, a); } - - turnOnLightLayer(a); // 4J - brought forward from 1.8.2 + + turnOnLightLayer(a); // 4J - brought forward from 1.8.2 { FRAME_PROFILE_SCOPE(Particle); particleEngine->renderLit(cameraEntity, a, @@ -1363,7 +1360,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { particleEngine->render(cameraEntity, a, ParticleEngine::OPAQUE_LIST); } - + turnOffLightLayer(a); // 4J - brought forward from 1.8.2 if ((mc->hitResult != nullptr) && @@ -1401,29 +1398,27 @@ void GameRenderer::renderLevel(float a, int64_t until) { } glBlendFunc(GL_ZERO, GL_ONE); - int visibleWaterChunks = + int visibleWaterChunks = levelRenderer->render(cameraEntity, 1, a, updateChunks); - + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); if (visibleWaterChunks > 0) { - levelRenderer->render( + levelRenderer->render( cameraEntity, 1, a, updateChunks); // 4J - chanaged, used to be // renderSameAsLast but we don't support // that anymore - } GL11::glShadeModel(GL11::GL_FLAT); } else { - levelRenderer->render(cameraEntity, 1, a, updateChunks); - + levelRenderer->render(cameraEntity, 1, a, updateChunks); } // 4J - added - have split out translucent particle rendering so that it // happens after the water is rendered, primarily for fireworks - Lighting::turnOn(); + Lighting::turnOn(); turnOnLightLayer(a); // 4J - brought forward from 1.8.2 { FRAME_PROFILE_SCOPE(Particle); @@ -1437,7 +1432,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { particleEngine->render(cameraEntity, a, ParticleEngine::TRANSLUCENT_LIST); } - + turnOffLightLayer(a); // 4J - brought forward from 1.8.2 ////////////////////////// End of 4J added section @@ -1460,7 +1455,7 @@ void GameRenderer::renderLevel(float a, int64_t until) { /* 4J - moved rain rendering to after clouds so that it alpha blends onto them properly renderSnowAndRain(a); - + glDisable(GL_FOG); */ @@ -1483,11 +1478,11 @@ void GameRenderer::renderLevel(float a, int64_t until) { // blend properly onto them setupFog(0, a); glEnable(GL_FOG); - { + { FRAME_PROFILE_SCOPE(WeatherSky); renderSnowAndRain(a); } - + glDisable(GL_FOG); if (zoom == 1) { @@ -1508,8 +1503,8 @@ void GameRenderer::prepareAndRenderClouds(LevelRenderer* levelRenderer, glPushMatrix(); setupFog(0, a); glEnable(GL_FOG); - levelRenderer->renderClouds(a); - + levelRenderer->renderClouds(a); + glDisable(GL_FOG); setupFog(1, a); glPopMatrix(); @@ -1557,11 +1552,9 @@ void GameRenderer::tickRain() { float za = random->nextFloat(); if (t > 0) { if (Tile::tiles[t]->material == Material::lava) { - mc->particleEngine->add( - std::make_shared( - level, x + xa, - y + 0.1f - Tile::tiles[t]->getShapeY0(), z + za, 0, - 0, 0)); + mc->particleEngine->add(std::make_shared( + level, x + xa, y + 0.1f - Tile::tiles[t]->getShapeY0(), + z + za, 0, 0, 0)); } else { if (random->nextInt(++rainPosSamples) == 0) { rainPosX = x + xa; @@ -1867,8 +1860,8 @@ void GameRenderer::setupClearColor(float a) { fb = (float)fogColor.z; if (mc->options->viewDistance < 2) { - Vec3 sunAngle = sinf(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0) - : Vec3(1, 0, 0); + Vec3 sunAngle = + sinf(level->getSunAngle(a)) > 0 ? Vec3(-1, 0, 0) : Vec3(1, 0, 0); float d = (float)player->getViewVector(a).dot(sunAngle); if (d < 0) d = 0; if (d > 0) { diff --git a/targets/minecraft/client/renderer/ItemInHandRenderer.cpp b/targets/minecraft/client/renderer/ItemInHandRenderer.cpp index 6abd9e8db..d050e7c1a 100644 --- a/targets/minecraft/client/renderer/ItemInHandRenderer.cpp +++ b/targets/minecraft/client/renderer/ItemInHandRenderer.cpp @@ -501,7 +501,8 @@ void ItemInHandRenderer::render(float a) { float swing1 = sinf(swing * std::numbers::pi); float swing2 = sinf((sqrt(swing)) * std::numbers::pi); - glTranslatef(-swing2 * 0.4f, sinf(sqrt(swing) * std::numbers::pi * 2) * 0.2f, + glTranslatef(-swing2 * 0.4f, + sinf(sqrt(swing) * std::numbers::pi * 2) * 0.2f, -swing1 * 0.2f); } @@ -597,10 +598,9 @@ void ItemInHandRenderer::render(float a) { std::shared_ptr data = Item::map->getSavedData(item, minecraft->level); - if (data != nullptr) + if (data != nullptr) minimap->render(minecraft->player, minecraft->textures, data, minecraft->player->entityId); - glPopMatrix(); } else if (item != nullptr) { @@ -635,7 +635,8 @@ void ItemInHandRenderer::render(float a) { float swing1 = sinf(swing * std::numbers::pi); float swing2 = sinf((sqrt(swing)) * std::numbers::pi); - glTranslatef(-swing2 * 0.4f, sinf(sqrt(swing) * std::numbers::pi * 2) * 0.2f, + glTranslatef(-swing2 * 0.4f, + sinf(sqrt(swing) * std::numbers::pi * 2) * 0.2f, -swing1 * 0.2f); } @@ -673,10 +674,10 @@ void ItemInHandRenderer::render(float a) { pow = ((pow * pow) + pow * 2) / 3; if (pow > 1) pow = 1; if (pow > 0.1f) { - glTranslatef(0, - sinf((timeHeld - 0.1f) * 1.3f) * 0.01f * - (pow - 0.1f), - 0); + glTranslatef( + 0, + sinf((timeHeld - 0.1f) * 1.3f) * 0.01f * (pow - 0.1f), + 0); } glTranslatef(0, 0, pow * 0.1f); @@ -721,7 +722,8 @@ void ItemInHandRenderer::render(float a) { float swing1 = sinf(swing * std::numbers::pi); float swing2 = sinf((sqrt(swing)) * std::numbers::pi); - glTranslatef(-swing2 * 0.3f, sinf(sqrt(swing) * std::numbers::pi * 2) * 0.4f, + glTranslatef(-swing2 * 0.3f, + sinf(sqrt(swing) * std::numbers::pi * 2) * 0.4f, -swing1 * 0.4f); } diff --git a/targets/minecraft/client/renderer/LevelRenderer.cpp b/targets/minecraft/client/renderer/LevelRenderer.cpp index 45f034a46..22b5f5fb1 100644 --- a/targets/minecraft/client/renderer/LevelRenderer.cpp +++ b/targets/minecraft/client/renderer/LevelRenderer.cpp @@ -981,8 +981,8 @@ void LevelRenderer::renderSky(float alpha) { { glRotatef(90, 1, 0, 0); glRotatef( - sinf(level[playerIndex]->getSunAngle(alpha)) < 0 ? 180 : 0, - 0, 0, 1); + sinf(level[playerIndex]->getSunAngle(alpha)) < 0 ? 180 : 0, 0, + 0, 1); glRotatef(90, 0, 0, 1); float r = c[0]; @@ -1798,7 +1798,7 @@ bool LevelRenderer::updateDirtyChunks() { // chunk(s) if (dirtyChunkPresent) { lastDirtyChunkFound = System::currentTimeMillis(); - + // Find nearest chunk that is dirty for (int p = 0; p < XUSER_MAX_COUNT; p++) { // It's possible that the localplayers member can be set to @@ -1934,7 +1934,6 @@ bool LevelRenderer::updateDirtyChunks() { } // app.DebugPrintf("[%d,%d,%d]\n",nearestClipChunks.empty(),considered,wouldBeNearButEmpty); } - } } @@ -2016,7 +2015,7 @@ bool LevelRenderer::updateDirtyChunks() { // totalTime += (endTime - startTime); // countTime++; // printf("%d : %f\n", countTime, (float)totalTime - /// (float)countTime); + /// (float)countTime); } // 4J Stu - Ignore this path when in constrained mode on Xbox One else { @@ -2073,7 +2072,7 @@ bool LevelRenderer::updateDirtyChunks() { // countTime++; // printf("%d : %f\n", countTime, (float)totalTime / //(float)countTime); - + } #endif else { @@ -2127,8 +2126,7 @@ void LevelRenderer::renderHit(std::shared_ptr player, HitResult* h, glBlendFunc(GL_SRC_ALPHA, GL_ONE); glColor4f( 1, 1, 1, - ((float)(sinf(Minecraft::currentTimeMillis() / 100.0f)) * 0.2f + - 0.4f) * + ((float)(sinf(Minecraft::currentTimeMillis() / 100.0f)) * 0.2f + 0.4f) * 0.5f); if (mode != 0 && inventoryItem != nullptr) { glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); @@ -2391,7 +2389,6 @@ void LevelRenderer::setDirty(int x0, int y0, int z0, int x1, int y1, int z1, dirtyChunksLockFreeStack.Push( (int*)(intptr_t)(uintptr_t)(index + 2)); #endif - } // setGlobalChunkFlag(x * 16, y * // 16, z * 16, level, CHUNK_FLAG_DIRTY); @@ -3113,8 +3110,7 @@ std::shared_ptr LevelRenderer::addParticleInternal( new FlameParticle(lev, x, y, z, xa, ya, za)); break; case eParticleType_lava: - particle = - std::make_shared(lev, x, y, z); + particle = std::make_shared(lev, x, y, z); break; case eParticleType_footstep: particle = std::shared_ptr( @@ -3349,7 +3345,8 @@ void LevelRenderer::levelEvent(std::shared_ptr source, int type, int x, random->nextDouble() * 0.2, random->nextGaussian() * .15); } - for (double a = 0; a < std::numbers::pi * 2.0; a += std::numbers::pi * 0.05) { + for (double a = 0; a < std::numbers::pi * 2.0; + a += std::numbers::pi * 0.05) { addParticle(eParticleType_ender, xp + cos(a) * 5, yp - .4, zp + sin(a) * 5, cos(a) * -5, 0, sin(a) * -5); addParticle(eParticleType_ender, xp + cos(a) * 5, yp - .4, diff --git a/targets/minecraft/client/renderer/LevelRenderer.h b/targets/minecraft/client/renderer/LevelRenderer.h index 6aa95d3c7..1e8cf0f05 100644 --- a/targets/minecraft/client/renderer/LevelRenderer.h +++ b/targets/minecraft/client/renderer/LevelRenderer.h @@ -193,7 +193,7 @@ private: // std::vector *sortedChunks[4]; // 4J - removed - not // sorting our chunks anymore std::vector chunks[4]; // 4J - now one per player - int lastPlayerCount[4]; // 4J - added + int lastPlayerCount[4]; // 4J - added int xChunks, yChunks, zChunks; int chunkLists; Minecraft* mc; @@ -271,10 +271,11 @@ public: int veryNearCount); // For chunk rebuilding to inform the manager // that a chunk (a 16x16x16 tile render chunk) // has been updated - void addAABBs(Level* level, AABB* box, - std::vector* boxes); // For game to get any AABBs that the - // user should be colliding with as - // render data has not yet been updated + void addAABBs( + Level* level, AABB* box, + std::vector* boxes); // For game to get any AABBs that the + // user should be colliding with as + // render data has not yet been updated void tick(); DestroyedTileManager(); ~DestroyedTileManager(); diff --git a/targets/minecraft/client/renderer/Tesselator.cpp b/targets/minecraft/client/renderer/Tesselator.cpp index 4294dfff1..f7ad41411 100644 --- a/targets/minecraft/client/renderer/Tesselator.cpp +++ b/targets/minecraft/client/renderer/Tesselator.cpp @@ -105,7 +105,8 @@ void Tesselator::end() { if (mode == GL_QUADS && TRIANGLE_MODE) { // glDrawArrays(GL_TRIANGLES, 0, vertices); // 4J - changed for xbox RenderManager.DrawVertices( - C4JRender::PRIMITIVE_TYPE_TRIANGLE_LIST, vertices, _array->data(), + C4JRender::PRIMITIVE_TYPE_TRIANGLE_LIST, vertices, + _array->data(), useCompactFormat360 ? C4JRender::VERTEX_TYPE_COMPRESSED : C4JRender::VERTEX_TYPE_PF3_TF2_CB4_NB4_XW1, @@ -122,8 +123,8 @@ void Tesselator::end() { int vertexCount = vertices; if (useCompactFormat360) { RenderManager.DrawVertices( - (C4JRender::ePrimitiveType)mode, vertexCount, _array->data(), - C4JRender::VERTEX_TYPE_COMPRESSED, + (C4JRender::ePrimitiveType)mode, vertexCount, + _array->data(), C4JRender::VERTEX_TYPE_COMPRESSED, C4JRender::PIXEL_SHADER_TYPE_STANDARD); } else { if (useProjectedTexturePixelShader) { diff --git a/targets/minecraft/client/renderer/Textures.cpp b/targets/minecraft/client/renderer/Textures.cpp index 73dfb1ac7..e26e274bc 100644 --- a/targets/minecraft/client/renderer/Textures.cpp +++ b/targets/minecraft/client/renderer/Textures.cpp @@ -340,7 +340,7 @@ void Textures::loadIndexedTextures() { } std::vector Textures::loadTexturePixels(TEXTURE_NAME texId, - const std::wstring& resourceName) { + const std::wstring& resourceName) { TexturePack* skin = skins->getSelected(); { @@ -383,7 +383,8 @@ std::vector Textures::loadTexturePixels(BufferedImage* img) { return loadTexturePixels(img, pixels); } -std::vector Textures::loadTexturePixels(BufferedImage* img, std::vector& pixels) { +std::vector Textures::loadTexturePixels(BufferedImage* img, + std::vector& pixels) { int w = img->getWidth(); int h = img->getHeight(); img->getRGB(0, 0, w, h, pixels, 0, w); @@ -461,7 +462,8 @@ void Textures::bindTextureLayers(ResourceLocation* resource) { continue; } - std::wstring resourceName = std::wstring(preLoaded[textureName]) + L".png"; + std::wstring resourceName = + std::wstring(preLoaded[textureName]) + L".png"; BufferedImage* image = readImage(textureName, resourceName); if (image == nullptr) { continue; @@ -513,7 +515,6 @@ void Textures::bindTextureLayers(ResourceLocation* resource) { (outA << 24) | (outR << 16) | (outG << 8) | outB; } } - } if (hasMergedPixels) { @@ -729,7 +730,6 @@ void Textures::loadTexture(BufferedImage* img, int id, bool blur, bool clamp) { pixels->put(newPixels); pixels->position(0)->limit(newPixels.size()); - if (MIPMAP) { // 4J-PB - In the new XDK, the CreateTexture will fail if the number of // mipmaps is higher than the width & height passed in will allow! @@ -827,11 +827,11 @@ std::vector Textures::anaglyph(std::vector& rawPixels) { result[i] = a << 24 | rr << 16 | gg << 8 | bb; } - return result; } -void Textures::replaceTexture(std::vector& rawPixels, int w, int h, int id) { +void Textures::replaceTexture(std::vector& rawPixels, int w, int h, + int id) { bind(id); // Removed in Java @@ -887,7 +887,8 @@ void Textures::replaceTexture(std::vector& rawPixels, int w, int h, int id) // 4J - added. This is a more minimal version of replaceTexture that assumes the // texture bytes are already in order, and so doesn't do any of the extra // copying round that the original java version does -void Textures::replaceTextureDirect(const std::vector& rawPixels, int w, int h, int id) { +void Textures::replaceTextureDirect(const std::vector& rawPixels, int w, + int h, int id) { glBindTexture(GL_TEXTURE_2D, id); // Remove in Java @@ -899,14 +900,15 @@ void Textures::replaceTextureDirect(const std::vector& rawPixels, int w, in glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - RenderManager.TextureDataUpdate(0, 0, w, h, const_cast(rawPixels.data()), 0); + RenderManager.TextureDataUpdate(0, 0, w, h, + const_cast(rawPixels.data()), 0); } // 4J - added. This is a more minimal version of replaceTexture that assumes the // texture bytes are already in order, and so doesn't do any of the extra // copying round that the original java version does -void Textures::replaceTextureDirect(const std::vector& rawPixels, int w, int h, - int id) { +void Textures::replaceTextureDirect(const std::vector& rawPixels, int w, + int h, int id) { glBindTexture(GL_TEXTURE_2D, id); // Remove in Java @@ -918,7 +920,8 @@ void Textures::replaceTextureDirect(const std::vector& rawPixels, int w, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - RenderManager.TextureDataUpdate(0, 0, w, h, const_cast(rawPixels.data()), 0); + RenderManager.TextureDataUpdate(0, 0, w, h, + const_cast(rawPixels.data()), 0); } void Textures::releaseTexture(int id) { diff --git a/targets/minecraft/client/renderer/Textures.h b/targets/minecraft/client/renderer/Textures.h index ebb80f6c4..b8b7b6964 100644 --- a/targets/minecraft/client/renderer/Textures.h +++ b/targets/minecraft/client/renderer/Textures.h @@ -305,11 +305,12 @@ private: public: std::vector loadTexturePixels(TEXTURE_NAME texId, - const std::wstring& resourceName); + const std::wstring& resourceName); private: std::vector loadTexturePixels(BufferedImage* img); - std::vector loadTexturePixels(BufferedImage* img, std::vector& pixels); + std::vector loadTexturePixels(BufferedImage* img, + std::vector& pixels); void setTextureFormat(const std::wstring& resourceName); // 4J added public: @@ -331,10 +332,10 @@ private: public: int loadTexture(int idx); // 4J added - int getTexture( - BufferedImage* img, - IPlatformRender::eTextureFormat format = IPlatformRender::TEXTURE_FORMAT_RxGyBzAw, - bool mipmap = true); + int getTexture(BufferedImage* img, + IPlatformRender::eTextureFormat format = + IPlatformRender::TEXTURE_FORMAT_RxGyBzAw, + bool mipmap = true); void loadTexture(BufferedImage* img, int id); void loadTexture(BufferedImage* img, int id, bool blur, bool clamp); diff --git a/targets/minecraft/client/renderer/TileRenderer.cpp b/targets/minecraft/client/renderer/TileRenderer.cpp index 0cb40cb5a..6e93e9b74 100644 --- a/targets/minecraft/client/renderer/TileRenderer.cpp +++ b/targets/minecraft/client/renderer/TileRenderer.cpp @@ -800,7 +800,8 @@ bool TileRenderer::tesselateBrewingStandInWorld(BrewingStandTile* tt, int x, int data = level->getData(x, y, z); for (int arm = 0; arm < 3; arm++) { - float angle = arm * std::numbers::pi * 2.0f / 3.0f + std::numbers::pi * 0.5f; + float angle = + arm * std::numbers::pi * 2.0f / 3.0f + std::numbers::pi * 0.5f; float u0 = tex->getU(8, true); float u1 = tex->getU1(true); @@ -2056,10 +2057,14 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y, corners[i].xRot(90 * std::numbers::pi / 180); - if (dir == Direction::NORTH) corners[i].yRot(0 * std::numbers::pi / 180); - if (dir == Direction::SOUTH) corners[i].yRot(180 * std::numbers::pi / 180); - if (dir == Direction::WEST) corners[i].yRot(90 * std::numbers::pi / 180); - if (dir == Direction::EAST) corners[i].yRot(-90 * std::numbers::pi / 180); + if (dir == Direction::NORTH) + corners[i].yRot(0 * std::numbers::pi / 180); + if (dir == Direction::SOUTH) + corners[i].yRot(180 * std::numbers::pi / 180); + if (dir == Direction::WEST) + corners[i].yRot(90 * std::numbers::pi / 180); + if (dir == Direction::EAST) + corners[i].yRot(-90 * std::numbers::pi / 180); corners[i].x += x + 0.5; corners[i].y += y + 5 / 16.0f; @@ -2145,10 +2150,14 @@ bool TileRenderer::tesselateTripwireSourceInWorld(Tile* tt, int x, int y, corners[i].xRot(50 * std::numbers::pi / 180); } - if (dir == Direction::NORTH) corners[i].yRot(0 * std::numbers::pi / 180); - if (dir == Direction::SOUTH) corners[i].yRot(180 * std::numbers::pi / 180); - if (dir == Direction::WEST) corners[i].yRot(90 * std::numbers::pi / 180); - if (dir == Direction::EAST) corners[i].yRot(-90 * std::numbers::pi / 180); + if (dir == Direction::NORTH) + corners[i].yRot(0 * std::numbers::pi / 180); + if (dir == Direction::SOUTH) + corners[i].yRot(180 * std::numbers::pi / 180); + if (dir == Direction::WEST) + corners[i].yRot(90 * std::numbers::pi / 180); + if (dir == Direction::EAST) + corners[i].yRot(-90 * std::numbers::pi / 180); corners[i].x += x + 0.5; corners[i].y += y + 5 / 16.0f; diff --git a/targets/minecraft/client/renderer/culling/ViewportCuller.cpp b/targets/minecraft/client/renderer/culling/ViewportCuller.cpp index 5b3ac5a04..ac2b64266 100644 --- a/targets/minecraft/client/renderer/culling/ViewportCuller.cpp +++ b/targets/minecraft/client/renderer/culling/ViewportCuller.cpp @@ -11,8 +11,10 @@ ViewportCuller::Face::Face(double x, double y, double z, float yRot, this->yc = y; this->zc = z; - xd = sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); - zd = -cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); + xd = sinf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi); + zd = -cosf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi); yd = -sinf(xRot / 180 * std::numbers::pi); cullOffs = xc * xd + yc * yd + zc * zd; @@ -59,8 +61,10 @@ ViewportCuller::ViewportCuller(std::shared_ptr mob, double y = mob->yOld + (mob->y - mob->yOld) * a; double z = mob->zOld + (mob->z - mob->zOld) * a; - double xd = sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); - double zd = -cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); + double xd = sinf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi); + double zd = -cosf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi); double yd = -sinf(xRot / 180 * std::numbers::pi); float xFov = 30; diff --git a/targets/minecraft/client/renderer/entity/BoatRenderer.cpp b/targets/minecraft/client/renderer/entity/BoatRenderer.cpp index d5e208f11..c057a0058 100644 --- a/targets/minecraft/client/renderer/entity/BoatRenderer.cpp +++ b/targets/minecraft/client/renderer/entity/BoatRenderer.cpp @@ -34,8 +34,7 @@ void BoatRenderer::render(std::shared_ptr _boat, double x, double y, float dmg = boat->getDamage() - a; if (dmg < 0) dmg = 0; if (hurt > 0) { - glRotatef(sinf(hurt) * hurt * dmg / 10 * boat->getHurtDir(), 1, 0, - 0); + glRotatef(sinf(hurt) * hurt * dmg / 10 * boat->getHurtDir(), 1, 0, 0); } float ss = 12 / 16.0f; diff --git a/targets/minecraft/client/renderer/entity/EnderDragonRenderer.cpp b/targets/minecraft/client/renderer/entity/EnderDragonRenderer.cpp index 9c56fc329..4af5a5374 100644 --- a/targets/minecraft/client/renderer/entity/EnderDragonRenderer.cpp +++ b/targets/minecraft/client/renderer/entity/EnderDragonRenderer.cpp @@ -31,7 +31,8 @@ void EnderDragonRenderer::setupRotations(std::shared_ptr _mob, // 4J - reorganised a bit so we can free allocations double lpComponents[3]; - std::vector lp = std::vector(lpComponents, lpComponents + 3); + std::vector lp = + std::vector(lpComponents, lpComponents + 3); mob->getLatencyPos(lp, 7, a); float yr = lp[0]; // mob->getLatencyPos(lp, 5, a); @@ -124,8 +125,10 @@ void EnderDragonRenderer::render(std::shared_ptr _mob, double x, glPushMatrix(); glTranslatef((float)x, (float)y + 2, (float)z); - glRotatef((float)(-atan2(zd, xd)) * 180.0f / std::numbers::pi - 90.0f, 0, 1, 0); - glRotatef((float)(-atan2(sdd, yd)) * 180.0f / std::numbers::pi - 90.0f, 1, 0, 0); + glRotatef((float)(-atan2(zd, xd)) * 180.0f / std::numbers::pi - 90.0f, + 0, 1, 0); + glRotatef((float)(-atan2(sdd, yd)) * 180.0f / std::numbers::pi - 90.0f, + 1, 0, 0); // 4J-PB - Rotating the healing beam too static float fRot = 0.0f; diff --git a/targets/minecraft/client/renderer/entity/ItemRenderer.cpp b/targets/minecraft/client/renderer/entity/ItemRenderer.cpp index 9cbfcec79..6f3421f03 100644 --- a/targets/minecraft/client/renderer/entity/ItemRenderer.cpp +++ b/targets/minecraft/client/renderer/entity/ItemRenderer.cpp @@ -78,8 +78,7 @@ void ItemRenderer::render(std::shared_ptr _itemEntity, double x, glPushMatrix(); float bob = - sinf((itemEntity->age + a) / 10.0f + itemEntity->bobOffs) * 0.1f + - 0.1f; + sinf((itemEntity->age + a) / 10.0f + itemEntity->bobOffs) * 0.1f + 0.1f; float spin = ((itemEntity->age + a) / 20.0f + itemEntity->bobOffs) * Mth::RAD_TO_DEG; @@ -234,8 +233,8 @@ void ItemRenderer::renderItemBillboard(std::shared_ptr entity, glRotatef(180, 0, 1, 0); } else { glRotatef( - ((entity->age + a) / 20.0f + entity->bobOffs) * Mth::RAD_TO_DEG, 0, - 1, 0); + ((entity->age + a) / 20.0f + entity->bobOffs) * Mth::RAD_TO_DEG, + 0, 1, 0); } float width = 1 / 16.0f; @@ -364,7 +363,7 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, if (item->getIconType() == Icon::TYPE_TERRAIN && TileRenderer::canRender(Tile::tiles[itemId]->getRenderShape())) { - textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS); + textures->bindTexture(&TextureAtlas::LOCATION_BLOCKS); Tile* tile = Tile::tiles[itemId]; glPushMatrix(); @@ -386,9 +385,9 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, tileRenderer->renderTile(tile, itemAuxValue, 1, fAlpha, useCompiled); glPopMatrix(); - + } else if (Item::items[itemId]->hasMultipleSpriteLayers()) { - // special double-layered + // special double-layered glDisable(GL_LIGHTING); ResourceLocation* location = getTextureLocation(item->getIconType()); @@ -412,9 +411,9 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, } } glEnable(GL_LIGHTING); - + } else { - glDisable(GL_LIGHTING); + glDisable(GL_LIGHTING); if (item->getIconType() == Icon::TYPE_TERRAIN) { textures->bindTexture( &TextureAtlas::LOCATION_BLOCKS); // L"/terrain.png")); @@ -441,7 +440,6 @@ void ItemRenderer::renderGuiItem(Font* font, Textures* textures, blit((int)x, (int)y, itemIcon, 16, 16); } glEnable(GL_LIGHTING); - } glEnable(GL_CULL_FACE); } diff --git a/targets/minecraft/client/renderer/entity/LivingEntityRenderer.cpp b/targets/minecraft/client/renderer/entity/LivingEntityRenderer.cpp index 14944dd89..41d5107aa 100644 --- a/targets/minecraft/client/renderer/entity/LivingEntityRenderer.cpp +++ b/targets/minecraft/client/renderer/entity/LivingEntityRenderer.cpp @@ -335,8 +335,10 @@ void LivingEntityRenderer::renderArrows(std::shared_ptr mob, zd *= -1; } float sd = (float)sqrt(xd * xd + zd * zd); - arrow->yRotO = arrow->yRot = (float)(atan2(xd, zd) * 180 / std::numbers::pi); - arrow->xRotO = arrow->xRot = (float)(atan2(yd, sd) * 180 / std::numbers::pi); + arrow->yRotO = arrow->yRot = + (float)(atan2(xd, zd) * 180 / std::numbers::pi); + arrow->xRotO = arrow->xRot = + (float)(atan2(yd, sd) * 180 / std::numbers::pi); double x = 0; double y = 0; double z = 0; diff --git a/targets/minecraft/client/renderer/entity/MinecartRenderer.cpp b/targets/minecraft/client/renderer/entity/MinecartRenderer.cpp index 22c77bd04..b63b563b0 100644 --- a/targets/minecraft/client/renderer/entity/MinecartRenderer.cpp +++ b/targets/minecraft/client/renderer/entity/MinecartRenderer.cpp @@ -83,8 +83,7 @@ void MinecartRenderer::render(std::shared_ptr _cart, double x, double y, float dmg = cart->getDamage() - a; if (dmg < 0) dmg = 0; if (hurt > 0) { - glRotatef(sinf(hurt) * hurt * dmg / 10 * cart->getHurtDir(), 1, 0, - 0); + glRotatef(sinf(hurt) * hurt * dmg / 10 * cart->getHurtDir(), 1, 0, 0); } int yOffset = cart->getDisplayOffset(); diff --git a/targets/minecraft/client/renderer/entity/ZombieRenderer.cpp b/targets/minecraft/client/renderer/entity/ZombieRenderer.cpp index 9eca7cb43..b01209fa0 100644 --- a/targets/minecraft/client/renderer/entity/ZombieRenderer.cpp +++ b/targets/minecraft/client/renderer/entity/ZombieRenderer.cpp @@ -108,7 +108,8 @@ void ZombieRenderer::setupRotations(std::shared_ptr _mob, float bob, float bodyRot, float a) { std::shared_ptr mob = std::dynamic_pointer_cast(_mob); if (mob->isConverting()) { - bodyRot += (float)(cos(mob->tickCount * 3.25) * std::numbers::pi * .25f); + bodyRot += + (float)(cos(mob->tickCount * 3.25) * std::numbers::pi * .25f); } HumanoidMobRenderer::setupRotations(mob, bob, bodyRot, a); } \ No newline at end of file diff --git a/targets/minecraft/client/renderer/texture/SimpleIcon.h b/targets/minecraft/client/renderer/texture/SimpleIcon.h index dc8cfcae6..7e86aee0b 100644 --- a/targets/minecraft/client/renderer/texture/SimpleIcon.h +++ b/targets/minecraft/client/renderer/texture/SimpleIcon.h @@ -1,7 +1,6 @@ #pragma once #include - #include "StitchedTexture.h" // 4J Added this class to store the uv data that we have pre-calculated and diff --git a/targets/minecraft/client/renderer/texture/Texture.cpp b/targets/minecraft/client/renderer/texture/Texture.cpp index 39841bfbc..625a82b4d 100644 --- a/targets/minecraft/client/renderer/texture/Texture.cpp +++ b/targets/minecraft/client/renderer/texture/Texture.cpp @@ -95,7 +95,8 @@ void Texture::_init(const std::wstring& name, int mode, int width, int height, if (width == -1 || height == -1) { valid = false; } else { - std::vector tempBytes = std::vector(width * height * depth * 4); + std::vector tempBytes = + std::vector(width * height * depth * 4); for (int index = 0; index < tempBytes.size(); index++) { tempBytes[index] = 0; } @@ -104,13 +105,13 @@ void Texture::_init(const std::wstring& name, int mode, int width, int height, data[0]->put(tempBytes); data[0]->position(0)->limit(tempBytes.size()); - if (mipmapped) { for (unsigned int level = 1; level < m_iMipLevels; ++level) { int ww = width >> level; int hh = height >> level; - std::vector tempBytes = std::vector(ww * hh * depth * 4); + std::vector tempBytes = + std::vector(ww * hh * depth * 4); for (int index = 0; index < tempBytes.size(); index++) { tempBytes[index] = 0; } @@ -119,7 +120,6 @@ void Texture::_init(const std::wstring& name, int mode, int width, int height, data[level]->clear(); data[level]->put(tempBytes); data[level]->position(0)->limit(tempBytes.size()); - } } @@ -393,7 +393,6 @@ void Texture::transferFromImage(BufferedImage* image) { data[0]->put(tempBytes); data[0]->limit(tempBytes.size()); - if (mipmapped || image->getData(1) != nullptr) { mipmapped = true; for (unsigned int level = 1; level < MAX_MIP_LEVELS; ++level) { @@ -478,7 +477,6 @@ void Texture::transferFromImage(BufferedImage* image) { } } - if (immediateUpdate) { updateOnGPU(); } else { diff --git a/targets/minecraft/client/renderer/texture/custom/CompassTexture.cpp b/targets/minecraft/client/renderer/texture/custom/CompassTexture.cpp index 7bb5e0b20..a9aec0994 100644 --- a/targets/minecraft/client/renderer/texture/custom/CompassTexture.cpp +++ b/targets/minecraft/client/renderer/texture/custom/CompassTexture.cpp @@ -69,7 +69,7 @@ void CompassTexture::updateFromPosition(Level* level, double x, double z, rot = rott; } else { double rotd = rott - rot; - while (rotd < -std::numbers::pi ) rotd += std::numbers::pi * 2; + while (rotd < -std::numbers::pi) rotd += std::numbers::pi * 2; while (rotd >= std::numbers::pi) rotd -= std::numbers::pi * 2; if (rotd < -1) rotd = -1; if (rotd > 1) rotd = 1; @@ -80,9 +80,9 @@ void CompassTexture::updateFromPosition(Level* level, double x, double z, // 4J Stu - We share data with another texture if (m_dataTexture != nullptr) { - int newFrame = - (int)(((rot / (std::numbers::pi * 2)) + 1.0) * m_dataTexture->frames->size()) % - m_dataTexture->frames->size(); + int newFrame = (int)(((rot / (std::numbers::pi * 2)) + 1.0) * + m_dataTexture->frames->size()) % + m_dataTexture->frames->size(); while (newFrame < 0) { newFrame = (newFrame + m_dataTexture->frames->size()) % m_dataTexture->frames->size(); @@ -95,7 +95,8 @@ void CompassTexture::updateFromPosition(Level* level, double x, double z, } } else { int newFrame = - (int)(((rot / (std::numbers::pi * 2)) + 1.0) * frames->size()) % frames->size(); + (int)(((rot / (std::numbers::pi * 2)) + 1.0) * frames->size()) % + frames->size(); while (newFrame < 0) { newFrame = (newFrame + frames->size()) % frames->size(); } diff --git a/targets/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp b/targets/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp index 06cd0040d..5c08f4b3c 100644 --- a/targets/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp +++ b/targets/minecraft/client/renderer/tileentity/EnchantTableRenderer.cpp @@ -35,7 +35,7 @@ void EnchantTableRenderer::render(std::shared_ptr _table, double x, glTranslatef(0, 0.1f + sin(tt * 0.1f) * 0.01f, 0); float orot = (table->rot - table->oRot); while (orot >= std::numbers::pi) orot -= std::numbers::pi * 2; - while (orot < -std::numbers::pi ) orot += std::numbers::pi * 2; + while (orot < -std::numbers::pi) orot += std::numbers::pi * 2; float yRot = table->oRot + orot * a; diff --git a/targets/minecraft/client/skins/AbstractTexturePack.cpp b/targets/minecraft/client/skins/AbstractTexturePack.cpp index db889d09c..e374ca849 100644 --- a/targets/minecraft/client/skins/AbstractTexturePack.cpp +++ b/targets/minecraft/client/skins/AbstractTexturePack.cpp @@ -196,10 +196,10 @@ void AbstractTexturePack::loadDefaultColourTable() { void AbstractTexturePack::loadDefaultHTMLColourTable() { if (app.hasArchiveFile(L"HTMLColours.col")) { - std::vector textColours = app.getArchiveFile(L"HTMLColours.col"); + std::vector textColours = + app.getArchiveFile(L"HTMLColours.col"); m_colourTable->loadColoursFromData(textColours.data(), textColours.size()); - } } diff --git a/targets/minecraft/client/skins/DLCTexturePack.cpp b/targets/minecraft/client/skins/DLCTexturePack.cpp index ca7c88a6b..da28d9e1c 100644 --- a/targets/minecraft/client/skins/DLCTexturePack.cpp +++ b/targets/minecraft/client/skins/DLCTexturePack.cpp @@ -225,10 +225,10 @@ void DLCTexturePack::loadColourTable() { // Load the text colours if (app.hasArchiveFile(L"HTMLColours.col")) { - std::vector textColours = app.getArchiveFile(L"HTMLColours.col"); + std::vector textColours = + app.getArchiveFile(L"HTMLColours.col"); m_colourTable->loadColoursFromData(textColours.data(), textColours.size()); - } } diff --git a/targets/minecraft/client/skins/DefaultTexturePack.cpp b/targets/minecraft/client/skins/DefaultTexturePack.cpp index 25a95054c..e9f94519e 100644 --- a/targets/minecraft/client/skins/DefaultTexturePack.cpp +++ b/targets/minecraft/client/skins/DefaultTexturePack.cpp @@ -14,7 +14,8 @@ DefaultTexturePack::DefaultTexturePack() void DefaultTexturePack::loadIcon() { if (app.hasArchiveFile(L"Graphics\\TexturePackIcon.png")) { - std::vector ba = app.getArchiveFile(L"Graphics\\TexturePackIcon.png"); + std::vector ba = + app.getArchiveFile(L"Graphics\\TexturePackIcon.png"); m_iconData = ba.data(); m_iconSize = static_cast(ba.size()); } diff --git a/targets/minecraft/client/title/TitleScreen.cpp b/targets/minecraft/client/title/TitleScreen.cpp index ae2c8e281..49ae37857 100644 --- a/targets/minecraft/client/title/TitleScreen.cpp +++ b/targets/minecraft/client/title/TitleScreen.cpp @@ -397,7 +397,7 @@ void TitleScreen::render(int xm, int ym, float a) { glRotatef(-20, 0, 0, 1); float sss = 1.8f - std::abs(sinf(System::currentTimeMillis() % 1000 / - 1000.0f * std::numbers::pi * 2) * + 1000.0f * std::numbers::pi * 2) * 0.1f); sss = sss * 100 / (font->width(splash) + 8 * 4); diff --git a/targets/minecraft/commands/common/EffectCommand.h b/targets/minecraft/commands/common/EffectCommand.h index 0042e5ea2..c00b39a4f 100644 --- a/targets/minecraft/commands/common/EffectCommand.h +++ b/targets/minecraft/commands/common/EffectCommand.h @@ -13,7 +13,8 @@ public: EGameCommand getId(); int getPermissionLevel(); std::wstring getUsage(CommandSender* source); - void execute(std::shared_ptr source, std::vector& commandData); + void execute(std::shared_ptr source, + std::vector& commandData); protected: std::wstring getPlayerNames(); diff --git a/targets/minecraft/commands/common/ToggleDownfallCommand.cpp b/targets/minecraft/commands/common/ToggleDownfallCommand.cpp index f061f65b4..f0146b25e 100644 --- a/targets/minecraft/commands/common/ToggleDownfallCommand.cpp +++ b/targets/minecraft/commands/common/ToggleDownfallCommand.cpp @@ -28,6 +28,6 @@ void ToggleDownfallCommand::doToggleDownfall() { } std::shared_ptr ToggleDownfallCommand::preparePacket() { - return std::shared_ptr( - new GameCommandPacket(eGameCommand_ToggleDownfall, std::vector())); + return std::shared_ptr(new GameCommandPacket( + eGameCommand_ToggleDownfall, std::vector())); } \ No newline at end of file diff --git a/targets/minecraft/core/ItemDispenseBehaviors.cpp b/targets/minecraft/core/ItemDispenseBehaviors.cpp index e190172f0..3a95768ab 100644 --- a/targets/minecraft/core/ItemDispenseBehaviors.cpp +++ b/targets/minecraft/core/ItemDispenseBehaviors.cpp @@ -50,16 +50,16 @@ std::shared_ptr ArrowDispenseBehavior::getProjectile( std::shared_ptr EggDispenseBehavior::getProjectile( Level* world, Position* position) { - return std::make_shared( - world, position->getX(), position->getY(), position->getZ()); + return std::make_shared(world, position->getX(), + position->getY(), position->getZ()); } /* Snowball */ std::shared_ptr SnowballDispenseBehavior::getProjectile( Level* world, Position* position) { - return std::make_shared( - world, position->getX(), position->getY(), position->getZ()); + return std::make_shared(world, position->getX(), position->getY(), + position->getZ()); } /* Exp Bottle */ @@ -164,8 +164,8 @@ std::shared_ptr FireworksDispenseBehavior::execute( double spawnZ = source->getZ() + facing->getStepZ(); std::shared_ptr firework = - std::make_shared( - world, spawnX, spawnY, spawnZ, dispensed); + std::make_shared(world, spawnX, spawnY, spawnZ, + dispensed); source->getWorld()->addEntity(firework); outcome = ACTIVATED_ITEM; @@ -347,8 +347,7 @@ std::shared_ptr EmptyBucketDispenseBehavior::execute( ->addItem(std::shared_ptr( new ItemInstance(targetType))) < 0) { DefaultDispenseItemBehavior::dispense( - source, - std::make_shared(targetType)); + source, std::make_shared(targetType)); } outcome = ACTIVATED_ITEM; diff --git a/targets/minecraft/network/Connection.cpp b/targets/minecraft/network/Connection.cpp index 219f3ee9b..3c8a64613 100644 --- a/targets/minecraft/network/Connection.cpp +++ b/targets/minecraft/network/Connection.cpp @@ -486,7 +486,6 @@ void Connection::tick() { // was locking up sometimes when disconnecting for (int i = 0; i < packetsToHandle.size(); i++) { packetsToHandle[i]->handle(packetListener); - } flush(); diff --git a/targets/minecraft/network/packet/AwardStatPacket.cpp b/targets/minecraft/network/packet/AwardStatPacket.cpp index bae0ab80c..2573c47d7 100644 --- a/targets/minecraft/network/packet/AwardStatPacket.cpp +++ b/targets/minecraft/network/packet/AwardStatPacket.cpp @@ -5,9 +5,7 @@ #include "java/InputOutputStream/DataInputStream.h" #include "java/InputOutputStream/DataOutputStream.h" -AwardStatPacket::AwardStatPacket() { - this->m_paramData.clear(); -} +AwardStatPacket::AwardStatPacket() { this->m_paramData.clear(); } AwardStatPacket::AwardStatPacket(int statId, int count) { this->statId = statId; @@ -26,9 +24,7 @@ AwardStatPacket::AwardStatPacket(int statId, std::vector& paramData) { this->m_paramData = paramData; } -AwardStatPacket::~AwardStatPacket() { - m_paramData.clear(); -} +AwardStatPacket::~AwardStatPacket() { m_paramData.clear(); } void AwardStatPacket::handle(PacketListener* listener) { listener->handleAwardStat(shared_from_this()); diff --git a/targets/minecraft/network/packet/BlockRegionUpdatePacket.cpp b/targets/minecraft/network/packet/BlockRegionUpdatePacket.cpp index f3193e956..3213660c8 100644 --- a/targets/minecraft/network/packet/BlockRegionUpdatePacket.cpp +++ b/targets/minecraft/network/packet/BlockRegionUpdatePacket.cpp @@ -71,7 +71,8 @@ BlockRegionUpdatePacket::BlockRegionUpdatePacket(int x, int y, int z, int xs, unsigned int inputSize = (256 * 16 * 16 * 5) / 2; Compression::getCompression()->CompressLZXRLE( - ucTemp, &inputSize, rawBuffer.data(), (unsigned int)rawBuffer.size()); + ucTemp, &inputSize, rawBuffer.data(), + (unsigned int)rawBuffer.size()); // app.DebugPrintf("Chunk (%d,%d) compressed from %d to size %d\n", // x>>4, z>>4, rawBuffer.size(), inputSize); unsigned char* ucTemp2 = new unsigned char[inputSize]; diff --git a/targets/minecraft/network/packet/ChunkTilesUpdatePacket.cpp b/targets/minecraft/network/packet/ChunkTilesUpdatePacket.cpp index 51975a616..b1531ff9e 100644 --- a/targets/minecraft/network/packet/ChunkTilesUpdatePacket.cpp +++ b/targets/minecraft/network/packet/ChunkTilesUpdatePacket.cpp @@ -6,8 +6,7 @@ #include "minecraft/world/level/Level.h" #include "minecraft/world/level/chunk/LevelChunk.h" -ChunkTilesUpdatePacket::~ChunkTilesUpdatePacket() { -} +ChunkTilesUpdatePacket::~ChunkTilesUpdatePacket() {} ChunkTilesUpdatePacket::ChunkTilesUpdatePacket() { shouldDelay = true; diff --git a/targets/minecraft/network/packet/ChunkTilesUpdatePacket.h b/targets/minecraft/network/packet/ChunkTilesUpdatePacket.h index e23c99cce..7334fbda9 100644 --- a/targets/minecraft/network/packet/ChunkTilesUpdatePacket.h +++ b/targets/minecraft/network/packet/ChunkTilesUpdatePacket.h @@ -23,8 +23,8 @@ public: ChunkTilesUpdatePacket(); ~ChunkTilesUpdatePacket(); - ChunkTilesUpdatePacket(int xc, int zc, std::vector& positions, uint8_t count, - Level* level); + ChunkTilesUpdatePacket(int xc, int zc, std::vector& positions, + uint8_t count, Level* level); virtual void read(DataInputStream* dis); virtual void write(DataOutputStream* dos); diff --git a/targets/minecraft/network/packet/ClientInformationPacket.h b/targets/minecraft/network/packet/ClientInformationPacket.h index ce67406fd..43a2e5022 100644 --- a/targets/minecraft/network/packet/ClientInformationPacket.h +++ b/targets/minecraft/network/packet/ClientInformationPacket.h @@ -1,4 +1,3 @@ #pragma once - class ClientInformationPacket : public Packet {}; \ No newline at end of file diff --git a/targets/minecraft/network/packet/ComplexItemDataPacket.cpp b/targets/minecraft/network/packet/ComplexItemDataPacket.cpp index d2ba4eca1..95dace19c 100644 --- a/targets/minecraft/network/packet/ComplexItemDataPacket.cpp +++ b/targets/minecraft/network/packet/ComplexItemDataPacket.cpp @@ -6,7 +6,6 @@ #include "java/InputOutputStream/DataInputStream.h" #include "java/InputOutputStream/DataOutputStream.h" - ComplexItemDataPacket::~ComplexItemDataPacket() {} ComplexItemDataPacket::ComplexItemDataPacket() { @@ -40,7 +39,8 @@ void ComplexItemDataPacket::write(DataOutputStream* dos) // throws IOException dos->writeShort(itemId); dos->writeUnsignedShort(data.size()); - std::vector ba((uint8_t*)data.data(), (uint8_t*)data.data() + data.size()); + std::vector ba((uint8_t*)data.data(), + (uint8_t*)data.data() + data.size()); dos->write(ba); } diff --git a/targets/minecraft/network/packet/ComplexItemDataPacket.h b/targets/minecraft/network/packet/ComplexItemDataPacket.h index fe15cb3f7..070ea5200 100644 --- a/targets/minecraft/network/packet/ComplexItemDataPacket.h +++ b/targets/minecraft/network/packet/ComplexItemDataPacket.h @@ -17,7 +17,8 @@ public: ComplexItemDataPacket(); ~ComplexItemDataPacket(); - ComplexItemDataPacket(short itemType, short itemId, std::vector& data); + ComplexItemDataPacket(short itemType, short itemId, + std::vector& data); virtual void read(DataInputStream* dis); virtual void write(DataOutputStream* dos); diff --git a/targets/minecraft/network/packet/ContainerSetContentPacket.cpp b/targets/minecraft/network/packet/ContainerSetContentPacket.cpp index 48dc420c3..94f93f773 100644 --- a/targets/minecraft/network/packet/ContainerSetContentPacket.cpp +++ b/targets/minecraft/network/packet/ContainerSetContentPacket.cpp @@ -11,7 +11,7 @@ ContainerSetContentPacket::~ContainerSetContentPacket() {} ContainerSetContentPacket::ContainerSetContentPacket() { containerId = 0; } ContainerSetContentPacket::ContainerSetContentPacket( - int containerId, std::vector >* newItems) { + int containerId, std::vector>* newItems) { this->containerId = containerId; items = std::vector>((int)newItems->size()); for (unsigned int i = 0; i < items.size(); i++) { diff --git a/targets/minecraft/network/packet/ContainerSetContentPacket.h b/targets/minecraft/network/packet/ContainerSetContentPacket.h index 374b88454..799a30b53 100644 --- a/targets/minecraft/network/packet/ContainerSetContentPacket.h +++ b/targets/minecraft/network/packet/ContainerSetContentPacket.h @@ -19,7 +19,7 @@ public: ContainerSetContentPacket(); ~ContainerSetContentPacket(); ContainerSetContentPacket( - int containerId, std::vector >* newItems); + int containerId, std::vector>* newItems); virtual void read(DataInputStream* dis); virtual void write(DataOutputStream* dos); diff --git a/targets/minecraft/network/packet/CustomPayloadPacket.h b/targets/minecraft/network/packet/CustomPayloadPacket.h index 715c091e2..a0cbc60bb 100644 --- a/targets/minecraft/network/packet/CustomPayloadPacket.h +++ b/targets/minecraft/network/packet/CustomPayloadPacket.h @@ -28,7 +28,8 @@ public: std::vector data; CustomPayloadPacket(); - CustomPayloadPacket(const std::wstring& identifier, std::vector data); + CustomPayloadPacket(const std::wstring& identifier, + std::vector data); virtual void read(DataInputStream* dis); virtual void write(DataOutputStream* dos); diff --git a/targets/minecraft/network/packet/GameCommandPacket.cpp b/targets/minecraft/network/packet/GameCommandPacket.cpp index 9fd127d05..b3e486255 100644 --- a/targets/minecraft/network/packet/GameCommandPacket.cpp +++ b/targets/minecraft/network/packet/GameCommandPacket.cpp @@ -12,7 +12,8 @@ GameCommandPacket::GameCommandPacket() { length = 0; } GameCommandPacket::~GameCommandPacket() {} -GameCommandPacket::GameCommandPacket(EGameCommand command, std::vector data) { +GameCommandPacket::GameCommandPacket(EGameCommand command, + std::vector data) { this->command = command; this->data = data; length = 0; @@ -31,7 +32,6 @@ GameCommandPacket::GameCommandPacket(EGameCommand command, std::vector } } - void GameCommandPacket::read(DataInputStream* dis) { command = (EGameCommand)dis->readInt(); length = dis->readShort(); diff --git a/targets/minecraft/network/packet/Packet.cpp b/targets/minecraft/network/packet/Packet.cpp index 5fb22c54a..6622b5d24 100644 --- a/targets/minecraft/network/packet/Packet.cpp +++ b/targets/minecraft/network/packet/Packet.cpp @@ -456,7 +456,8 @@ std::shared_ptr Packet::getPacket(int id) { return idToCreateMap[id](); } -void Packet::writeBytes(DataOutputStream* dataoutputstream, const std::vector& bytes) { +void Packet::writeBytes(DataOutputStream* dataoutputstream, + const std::vector& bytes) { dataoutputstream->writeShort(bytes.size()); dataoutputstream->write(bytes); } @@ -670,8 +671,7 @@ std::shared_ptr Packet::readItem(DataInputStream* dis) { int count = dis->readByte(); int damage = dis->readShort(); - item = - std::make_shared(id, count, damage); + item = std::make_shared(id, count, damage); // 4J Stu - Always read/write the tag // if (Item.items[id].canBeDepleted() || // Item.items[id].shouldOverrideMultiplayerNBT()) diff --git a/targets/minecraft/network/packet/Packet.h b/targets/minecraft/network/packet/Packet.h index 13078d82c..c3adf31b6 100644 --- a/targets/minecraft/network/packet/Packet.h +++ b/targets/minecraft/network/packet/Packet.h @@ -74,7 +74,8 @@ public: // 4J Added static bool canSendToAnyClient(std::shared_ptr packet); - static void writeBytes(DataOutputStream* dataoutputstream, const std::vector& bytes); + static void writeBytes(DataOutputStream* dataoutputstream, + const std::vector& bytes); static std::vector readBytes(DataInputStream* datainputstream); virtual int getId() = 0; diff --git a/targets/minecraft/network/packet/PreLoginPacket.cpp b/targets/minecraft/network/packet/PreLoginPacket.cpp index c320c42bc..e87188611 100644 --- a/targets/minecraft/network/packet/PreLoginPacket.cpp +++ b/targets/minecraft/network/packet/PreLoginPacket.cpp @@ -16,7 +16,7 @@ PreLoginPacket::PreLoginPacket() { m_dwPlayerCount = 0; m_friendsOnlyBits = 0; m_ugcPlayersVersion = 0; - memset(m_szUniqueSaveName, 0, m_iSaveNameLen); + memset(m_szUniqueSaveName, 0, m_iSaveNameLen); m_serverSettings = 0; m_hostIndex = 0; m_texturePackId = 0; @@ -29,7 +29,7 @@ PreLoginPacket::PreLoginPacket(std::wstring userName) { m_dwPlayerCount = 0; m_friendsOnlyBits = 0; m_ugcPlayersVersion = 0; - memset(m_szUniqueSaveName, 0, m_iSaveNameLen); + memset(m_szUniqueSaveName, 0, m_iSaveNameLen); m_serverSettings = 0; m_hostIndex = 0; m_texturePackId = 0; diff --git a/targets/minecraft/network/packet/RemoveEntitiesPacket.cpp b/targets/minecraft/network/packet/RemoveEntitiesPacket.cpp index ba9dd8123..3a48e32e5 100644 --- a/targets/minecraft/network/packet/RemoveEntitiesPacket.cpp +++ b/targets/minecraft/network/packet/RemoveEntitiesPacket.cpp @@ -5,11 +5,12 @@ RemoveEntitiesPacket::RemoveEntitiesPacket() {} -RemoveEntitiesPacket::RemoveEntitiesPacket(std::vector& ids) { this->ids = ids; } - -RemoveEntitiesPacket::~RemoveEntitiesPacket() { +RemoveEntitiesPacket::RemoveEntitiesPacket(std::vector& ids) { + this->ids = ids; } +RemoveEntitiesPacket::~RemoveEntitiesPacket() {} + void RemoveEntitiesPacket::read(DataInputStream* dis) // throws IOException { ids = std::vector(dis->readByte()); diff --git a/targets/minecraft/network/packet/SetHealthPacket.cpp b/targets/minecraft/network/packet/SetHealthPacket.cpp index 8faa1f1ee..ccc493b86 100644 --- a/targets/minecraft/network/packet/SetHealthPacket.cpp +++ b/targets/minecraft/network/packet/SetHealthPacket.cpp @@ -8,7 +8,7 @@ SetHealthPacket::SetHealthPacket() { this->food = 0; this->saturation = 0; - this->damageSource = 0; // 4jcraft: previously eTelemetryChallenges_Unknown + this->damageSource = 0; // 4jcraft: previously eTelemetryChallenges_Unknown } SetHealthPacket::SetHealthPacket(float health, int food, float saturation, diff --git a/targets/minecraft/server/MinecraftServer.cpp b/targets/minecraft/server/MinecraftServer.cpp index e50b6adbe..c48644916 100644 --- a/targets/minecraft/server/MinecraftServer.cpp +++ b/targets/minecraft/server/MinecraftServer.cpp @@ -255,9 +255,8 @@ int MinecraftServer::runPostUpdate(void* lpParam) { server->m_postProcessRequests.pop_back(); lock.unlock(); static int count = 0; - request.chunkSource->postProcess(request.chunkSource, request.x, + request.chunkSource->postProcess(request.chunkSource, request.x, request.z); - } } std::this_thread::sleep_for(std::chrono::milliseconds(1)); @@ -405,9 +404,8 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, storage = std::shared_ptr( new McRegionLevelStorage(newFormatSave, File(L"."), name, true)); #else - storage = - std::make_shared( - new ConsoleSaveFileOriginal(L""), File(L"."), name, true); + storage = std::make_shared( + new ConsoleSaveFileOriginal(L""), File(L"."), name, true); #endif } @@ -582,11 +580,11 @@ bool MinecraftServer::loadLevel(LevelStorageSource* storageSource, // lastTime = now; } static int count = 0; - level->cache->create((spawnPos->x + x) >> 4, + level->cache->create((spawnPos->x + x) >> 4, (spawnPos->z + z) >> 4, true); // 4J - added parameter to // disable postprocessing here - + // while (level->updateLights() && // running) // ; @@ -822,20 +820,18 @@ void MinecraftServer::saveGameRules() { unsigned int length; csf->writeFile(fe, ba.data(), ba.size(), &length); - csf->closeHandle(fe); } } } void MinecraftServer::Suspend() { - m_suspending = true; + m_suspending = true; // Get the frequency of the timer float fElapsedTime = 0.0f; // Save the start time auto qwTime = PlatformTime::QueryPerformanceCounter(); - if (m_bLoaded && - (!StorageManager.GetSaveDisabled())) { + if (m_bLoaded && (!StorageManager.GetSaveDisabled())) { if (players != nullptr) { players->saveAll(nullptr); } @@ -855,11 +851,11 @@ void MinecraftServer::Suspend() { } auto qwNewTime = PlatformTime::QueryPerformanceCounter(); - fElapsedTime = static_cast(PlatformTime::ElapsedSeconds(qwTime, qwNewTime)); + fElapsedTime = + static_cast(PlatformTime::ElapsedSeconds(qwTime, qwNewTime)); m_suspending = false; app.DebugPrintf("Suspend server: Elapsed time %f\n", fElapsedTime); - } bool MinecraftServer::IsSuspending() { return m_suspending; } @@ -885,8 +881,7 @@ 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 && - (!StorageManager.GetSaveDisabled()) && didInit) { + if (m_saveOnExit && (!StorageManager.GetSaveDisabled()) && didInit) { if (players != nullptr) { players->saveAll(Minecraft::GetInstance()->progressRenderer, true); @@ -1441,13 +1436,12 @@ void MinecraftServer::tick() { // #ifndef 0 static int64_t stc = 0; int64_t st0 = System::currentTimeMillis(); - ((Level*)level)->tick(); + ((Level*)level)->tick(); int64_t st1 = System::currentTimeMillis(); - - + int64_t st2 = System::currentTimeMillis(); - - // 4J added to stop ticking entities in levels when players are not + + // 4J added to stop ticking entities in levels when players are not // in those levels. Note: now changed so that we also tick if there // are entities to be removed, as this also happens as a result of // calling tickEntities. If we don't do this, then the entities get @@ -1460,10 +1454,8 @@ void MinecraftServer::tick() { (level->hasEntitiesToRemove())) { level->tickEntities(); } - - level->getTracker()->tick(); - + level->getTracker()->tick(); int64_t st3 = System::currentTimeMillis(); // printf(">>>>>>>>>>>>>>>>>>>>>> Tick %d %d %d : @@ -1474,10 +1466,9 @@ void MinecraftServer::tick() { } Entity::tickExtraWandering(); // 4J added - connection->tick(); - - players->tick(); - + connection->tick(); + + players->tick(); // 4J - removed diff --git a/targets/minecraft/server/PlayerList.cpp b/targets/minecraft/server/PlayerList.cpp index 743ad20dd..1ec644ed7 100644 --- a/targets/minecraft/server/PlayerList.cpp +++ b/targets/minecraft/server/PlayerList.cpp @@ -99,7 +99,7 @@ void PlayerList::placeNewPlayer(Connection* connection, std::uint8_t playerIndex = 0; { bool usedIndexes[MINECRAFT_NET_MAX_PLAYERS]; - memset(&usedIndexes, 0, MINECRAFT_NET_MAX_PLAYERS * sizeof(bool)); + memset(&usedIndexes, 0, MINECRAFT_NET_MAX_PLAYERS * sizeof(bool)); for (auto it = players.begin(); it < players.end(); ++it) { usedIndexes[(int)(*it)->getPlayerIndex()] = true; } @@ -449,8 +449,7 @@ void PlayerList::add(std::shared_ptr player) { // broadcastAll(std::shared_ptr( new // PlayerInfoPacket(player->name, true, 1000) ) ); if (player->connection->getNetworkPlayer()) { - broadcastAll( - std::make_shared(player)); + broadcastAll(std::make_shared(player)); } players.push_back(player); @@ -478,8 +477,7 @@ void PlayerList::add(std::shared_ptr player) { // player->connection->send(std::shared_ptr( new // PlayerInfoPacket(op->name, true, op->latency) ) ); if (op->connection->getNetworkPlayer()) { - player->connection->send( - std::make_shared(op)); + player->connection->send(std::make_shared(op)); } } @@ -490,9 +488,8 @@ void PlayerList::add(std::shared_ptr player) { if (thisPlayer->isSleeping()) { if (firstSleepingPlayer == nullptr) firstSleepingPlayer = thisPlayer; - thisPlayer->connection->send( - std::make_shared( - thisPlayer->name, ChatPacket::e_ChatBedMeSleep)); + thisPlayer->connection->send(std::make_shared( + thisPlayer->name, ChatPacket::e_ChatBedMeSleep)); } } player->connection->send(std::make_shared( @@ -720,9 +717,8 @@ std::shared_ptr PlayerList::respawn( respawnPosition->z + 0.5f, 0, 0); player->setRespawnPosition(bedPosition, spawnForced); } else { - player->connection->send( - std::make_shared( - GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0)); + player->connection->send(std::make_shared( + GameEventPacket::NO_RESPAWN_BED_AVAILABLE, 0)); } delete bedPosition; } @@ -743,10 +739,9 @@ std::shared_ptr PlayerList::respawn( level->getLevelData()->getHellScale())); player->connection->teleport(player->x, player->y, player->z, player->yRot, player->xRot); - player->connection->send( - std::make_shared( - player->experienceProgress, player->totalExperience, - player->experienceLevel)); + player->connection->send(std::make_shared( + player->experienceProgress, player->totalExperience, + player->experienceLevel)); if (keepAllPlayerData) { std::vector* activeEffects = @@ -990,8 +985,7 @@ void PlayerList::tick() { // broadcastAll(std::shared_ptr( new // PlayerInfoPacket(op->name, true, op->latency) ) ); if (op->connection->getNetworkPlayer()) { - broadcastAll( - std::make_shared(op)); + broadcastAll(std::make_shared(op)); } } @@ -1284,8 +1278,7 @@ void PlayerList::sendMessage(const std::wstring& name, const std::wstring& message) { std::shared_ptr player = getPlayer(name); if (player != nullptr) { - player->connection->send( - std::make_shared(message)); + player->connection->send(std::make_shared(message)); } } diff --git a/targets/minecraft/server/level/GameMode.cpp b/targets/minecraft/server/level/GameMode.cpp index 15fc7c580..388ad1410 100644 --- a/targets/minecraft/server/level/GameMode.cpp +++ b/targets/minecraft/server/level/GameMode.cpp @@ -96,8 +96,8 @@ void GameMode::adjustPlayer(std::shared_ptr player) {} // } std::shared_ptr GameMode::createPlayer(Level* level) { - return std::make_shared( - minecraft, level, minecraft->user, level->dimension->id); + return std::make_shared(minecraft, level, minecraft->user, + level->dimension->id); } bool GameMode::interact(std::shared_ptr player, diff --git a/targets/minecraft/server/level/PlayerChunkMap.cpp b/targets/minecraft/server/level/PlayerChunkMap.cpp index 1027dc834..baf4514c6 100644 --- a/targets/minecraft/server/level/PlayerChunkMap.cpp +++ b/targets/minecraft/server/level/PlayerChunkMap.cpp @@ -380,9 +380,8 @@ bool PlayerChunkMap::PlayerChunk::broadcastChanges(bool allowRegionUpdate) { // 4J As we only get here if changes is less than // MAX_CHANGES_BEFORE_RESEND (10) we only need to send a byte value in // the packet - broadcast( - std::make_shared( - pos.x, pos.z, changedTiles, (uint8_t)changes, level)); + broadcast(std::make_shared( + pos.x, pos.z, changedTiles, (uint8_t)changes, level)); for (int i = 0; i < changes; i++) { int x = pos.x * 16 + ((changedTiles[i] >> 12) & 15); int y = ((changedTiles[i]) & 255); diff --git a/targets/minecraft/server/level/ServerChunkCache.cpp b/targets/minecraft/server/level/ServerChunkCache.cpp index 8e8df1cc7..7112b826c 100644 --- a/targets/minecraft/server/level/ServerChunkCache.cpp +++ b/targets/minecraft/server/level/ServerChunkCache.cpp @@ -29,8 +29,7 @@ ServerChunkCache::ServerChunkCache(ServerLevel* level, ChunkStorage* storage, autoCreate = false; // 4J added std::vector emptyBlocks(Level::CHUNK_TILE_COUNT); - emptyChunk = - new EmptyLevelChunk(level, emptyBlocks, 0, 0); + emptyChunk = new EmptyLevelChunk(level, emptyBlocks, 0, 0); this->level = level; this->storage = storage; @@ -546,7 +545,7 @@ void ServerChunkCache::flagPostProcessComplete(short flag, int x, int z) { if ((lc->terrainPopulated & LevelChunk::sTerrainPopulatedAllAffecting) == LevelChunk::sTerrainPopulatedAllAffecting) { // Do the compression of data & lighting at this point - + // Check, using lower blocks as a reference, if we've already compressed // - no point doing this multiple times, which otherwise we will do as // we aren't checking for the flags transitioning in the if statement @@ -554,8 +553,6 @@ void ServerChunkCache::flagPostProcessComplete(short flag, int x, int z) { if (!lc->isLowerBlockStorageCompressed()) lc->compressBlocks(); if (!lc->isLowerBlockLightStorageCompressed()) lc->compressLighting(); if (!lc->isLowerDataStorageCompressed()) lc->compressData(); - - } // Are all neighbouring chunks And this one now post-processed? @@ -565,14 +562,12 @@ void ServerChunkCache::flagPostProcessComplete(short flag, int x, int z) { // This would be a good time to fix up any lighting for this chunk since // all the geometry that could affect it should now be in place - if (lc->level->dimension->id != 1) { + if (lc->level->dimension->id != 1) { lc->recheckGaps(true); } - // Do a checkLight on any tiles which are lava. - lc->lightLava(); - + lc->lightLava(); // Flag as now having this post-post-processing stage completed lc->terrainPopulated |= LevelChunk::sTerrainPostPostProcessed; @@ -584,8 +579,7 @@ void ServerChunkCache::postProcess(ChunkSource* parent, int x, int z) { if ((chunk->terrainPopulated & LevelChunk::sTerrainPopulatedFromHere) == 0) { if (source != nullptr) { - source->postProcess(parent, x, z); - + source->postProcess(parent, x, z); chunk->markUnsaved(); } @@ -648,20 +642,16 @@ void ServerChunkCache::postProcess(ChunkSource* parent, int x, int z) { // 4J Added for suspend bool ServerChunkCache::saveAllEntities() { - - { + { std::lock_guard lock(m_csLoadCreate); for (auto it = m_loadedChunkList.begin(); it != m_loadedChunkList.end(); ++it) { storage->saveEntities(level, *it); } } - - storage->flush(); - + storage->flush(); - return true; } @@ -866,16 +856,13 @@ int ServerChunkCache::runSaveThreadProc(void* lpParam) { // app.DebugPrintf("Save thread has started\n"); while (params->chunkToSave != nullptr) { - // app.DebugPrintf("Save thread has started processing a chunk\n"); + // app.DebugPrintf("Save thread has started processing a chunk\n"); if (params->saveEntities) params->cache->saveEntities(params->chunkToSave); - - + params->cache->save(params->chunkToSave); params->chunkToSave->setUnsaved(false); - - // Inform the producer thread that we are done with this chunk params->notificationEvent ->set(); // SetEvent(params->notificationEvent); @@ -887,7 +874,6 @@ int ServerChunkCache::runSaveThreadProc(void* lpParam) { params->wakeEvent->waitForSignal( C4JThread:: kInfiniteTimeout); // WaitForSingleObject(params->wakeEvent,INFINITE); - } // app.DebugPrintf("Thread is exiting as it has no chunk to process\n"); diff --git a/targets/minecraft/server/level/ServerLevel.cpp b/targets/minecraft/server/level/ServerLevel.cpp index 668eb4de6..6dacdc6a0 100644 --- a/targets/minecraft/server/level/ServerLevel.cpp +++ b/targets/minecraft/server/level/ServerLevel.cpp @@ -240,7 +240,7 @@ void ServerLevel::tick() { awakenAllPlayers(); } - // for Minecraft 1.8, spawn friendlies really rarely - 4J - altered + // for Minecraft 1.8, spawn friendlies really rarely - 4J - altered // from once every 400 ticks to 40 ticks as we depend on this a more than // the original since we don't have chunk post-process spawning if (getGameRules()->getBoolean(GameRules::RULE_DOMOBSPAWNING)) { @@ -263,9 +263,9 @@ void ServerLevel::tick() { mobSpawner->tick(this, finalSpawnEnemies, finalSpawnFriendlies, finalSpawnPersistent); } - - chunkSource->tick(); - + + chunkSource->tick(); + int newDark = getOldSkyDarken(1); if (newDark != skyDarken) { skyDarken = newDark; @@ -293,8 +293,7 @@ void ServerLevel::tick() { #endif { // app.DebugPrintf("Incremental save\n"); - save(false, nullptr); - + save(false, nullptr); } // 4J : WESTY : Changed so that time update goes through stats tracking @@ -315,25 +314,20 @@ void ServerLevel::tick() { } } - // if (tickCount % 5 == 0) { + // if (tickCount % 5 == 0) { tickPendingTicks(false); - - tickTiles(); - + tickTiles(); chunkMap->tick(); - villages->tick(); + villages->tick(); villageSiege->tick(); - - portalForcer->tick(getGameTime()); - + portalForcer->tick(getGameTime()); // repeat after tile ticks - runTileEvents(); - + runTileEvents(); // 4J Added runQueuedSendTileUpdates(); @@ -930,8 +924,7 @@ void ServerLevel::save(bool force, ProgressListener* progressListener, progressListener->progressStartNoAbort(IDS_PROGRESS_SAVING_LEVEL); } } - saveLevelData(); - + saveLevelData(); if (progressListener != nullptr) progressListener->progressStage(IDS_PROGRESS_SAVING_CHUNKS); @@ -1202,10 +1195,9 @@ void ServerLevel::sendParticles(const std::wstring& name, double x, double y, void ServerLevel::sendParticles(const std::wstring& name, double x, double y, double z, int count, double xDist, double yDist, double zDist, double speed) { - std::shared_ptr packet = - std::make_shared( - name, (float)x, (float)y, (float)z, (float)xDist, (float)yDist, - (float)zDist, (float)speed, count); + std::shared_ptr packet = std::make_shared( + name, (float)x, (float)y, (float)z, (float)xDist, (float)yDist, + (float)zDist, (float)speed, count); for (auto it = players.begin(); it != players.end(); ++it) { std::shared_ptr player = @@ -1418,7 +1410,7 @@ int ServerLevel::runUpdate(void* lpParam) { if (!ShutdownManager::ShouldRun(ShutdownManager::eRunUpdateThread)) break; - // 4J Stu - Grass and Lava ticks currently take up the majority of all + // 4J Stu - Grass and Lava ticks currently take up the majority of all // tile updates, so I am limiting them int grassTicks = 0; int lavaTicks = 0; @@ -1514,7 +1506,6 @@ int ServerLevel::runUpdate(void* lpParam) { } } } - } ShutdownManager::HasFinished(ShutdownManager::eRunUpdateThread); diff --git a/targets/minecraft/server/level/ServerPlayer.cpp b/targets/minecraft/server/level/ServerPlayer.cpp index 652903be6..64c5e9320 100644 --- a/targets/minecraft/server/level/ServerPlayer.cpp +++ b/targets/minecraft/server/level/ServerPlayer.cpp @@ -139,8 +139,7 @@ ServerPlayer::ServerPlayer(MinecraftServer* server, Level* level, lastBrupSendTickCount = 0; } -ServerPlayer::~ServerPlayer() { -} +ServerPlayer::~ServerPlayer() {} // 4J added - add bits to a flag array that is passed in, to represent those // entities which have small Ids, and are in our vector of entitiesToRemove. If @@ -437,7 +436,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { connection->getNetworkPlayer(), flagIndex)) { // app.DebugPrintf("Creating // BRUP for %d %d\n",nearest.x, nearest.z); - int64_t before = System::currentTimeMillis(); + int64_t before = System::currentTimeMillis(); std::shared_ptr packet = std::shared_ptr( new BlockRegionUpdatePacket( @@ -446,7 +445,7 @@ void ServerPlayer::doChunkSendingTick(bool dontDelayChunks) { int64_t after = System::currentTimeMillis(); // app.DebugPrintf(">>><<< //%d ms\n",after-before); - + if (dontDelayChunks) packet->shouldDelay = false; if (packet->shouldDelay == true) { @@ -587,9 +586,8 @@ void ServerPlayer::doTickB() { if (totalExperience != lastSentExp) { lastSentExp = totalExperience; - connection->send( - std::make_shared( - experienceProgress, totalExperience, experienceLevel)); + connection->send(std::make_shared( + experienceProgress, totalExperience, experienceLevel)); } } @@ -708,9 +706,8 @@ void ServerPlayer::changeDimension(int i) { wonGame = true; m_enteredEndExitPortal = true; // We only flag this for the player in the portal - connection->send( - std::make_shared( - GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex())); + connection->send(std::make_shared( + GameEventPacket::WIN_GAME, thisPlayer->GetUserIndex())); app.DebugPrintf("Sending packet to %d\n", thisPlayer->GetUserIndex()); } @@ -811,9 +808,8 @@ void ServerPlayer::stopSleepInBed(bool forcefulWakeUp, bool updateLevelList, void ServerPlayer::ride(std::shared_ptr e) { Player::ride(e); - connection->send( - std::make_shared( - SetEntityLinkPacket::RIDING, shared_from_this(), riding)); + connection->send(std::make_shared( + SetEntityLinkPacket::RIDING, shared_from_this(), riding)); // 4J Removed this - The act of riding will be handled on the client and // will change the position of the player. If we also teleport it then we @@ -835,9 +831,8 @@ void ServerPlayer::openTextEdit(std::shared_ptr sign) { if (signTE != nullptr) { signTE->setAllowedPlayerEditor( std::dynamic_pointer_cast(shared_from_this())); - connection->send( - std::make_shared( - TileEditorOpenPacket::SIGN, sign->x, sign->y, sign->z)); + connection->send(std::make_shared( + TileEditorOpenPacket::SIGN, sign->x, sign->y, sign->z)); } } @@ -848,10 +843,8 @@ void ServerPlayer::nextContainerCounter() { bool ServerPlayer::startCrafting(int x, int y, int z) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::WORKBENCH, L"", 9, - false)); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::WORKBENCH, L"", 9, false)); containerMenu = new CraftingMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -867,10 +860,8 @@ bool ServerPlayer::startCrafting(int x, int y, int z) { bool ServerPlayer::openFireworks(int x, int y, int z) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, - false)); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false)); containerMenu = new FireworksMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -878,10 +869,8 @@ bool ServerPlayer::openFireworks(int x, int y, int z) { closeContainer(); nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, - false)); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::FIREWORKS, L"", 9, false)); containerMenu = new FireworksMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -898,10 +887,9 @@ bool ServerPlayer::startEnchanting(int x, int y, int z, const std::wstring& name) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::ENCHANTMENT, - name.empty() ? L"" : name, 9, !name.empty())); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::ENCHANTMENT, + name.empty() ? L"" : name, 9, !name.empty())); containerMenu = new EnchantmentMenu(inventory, level, x, y, z); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -917,10 +905,9 @@ bool ServerPlayer::startEnchanting(int x, int y, int z, bool ServerPlayer::startRepairing(int x, int y, int z) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::REPAIR_TABLE, L"", 9, - false)); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::REPAIR_TABLE, L"", 9, + false)); containerMenu = new AnvilMenu( inventory, level, x, y, z, std::dynamic_pointer_cast(shared_from_this())); @@ -944,10 +931,9 @@ bool ServerPlayer::openContainer(std::shared_ptr container) { int containerType = container->getContainerType(); assert(containerType >= 0); - connection->send( - std::make_shared( - containerCounter, containerType, container->getCustomName(), - container->getContainerSize(), container->hasCustomName())); + connection->send(std::make_shared( + containerCounter, containerType, container->getCustomName(), + container->getContainerSize(), container->hasCustomName())); containerMenu = new ContainerMenu(inventory, container); containerMenu->containerId = containerCounter; @@ -963,11 +949,10 @@ bool ServerPlayer::openContainer(std::shared_ptr container) { bool ServerPlayer::openHopper(std::shared_ptr container) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::HOPPER, - container->getCustomName(), container->getContainerSize(), - container->hasCustomName())); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::HOPPER, + container->getCustomName(), container->getContainerSize(), + container->hasCustomName())); containerMenu = new HopperMenu(inventory, container); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -983,11 +968,10 @@ bool ServerPlayer::openHopper(std::shared_ptr container) { bool ServerPlayer::openHopper(std::shared_ptr container) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::HOPPER, - container->getCustomName(), container->getContainerSize(), - container->hasCustomName())); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::HOPPER, + container->getCustomName(), container->getContainerSize(), + container->hasCustomName())); containerMenu = new HopperMenu(inventory, container); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1003,11 +987,10 @@ bool ServerPlayer::openHopper(std::shared_ptr container) { bool ServerPlayer::openFurnace(std::shared_ptr furnace) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::FURNACE, - furnace->getCustomName(), furnace->getContainerSize(), - furnace->hasCustomName())); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::FURNACE, + furnace->getCustomName(), furnace->getContainerSize(), + furnace->hasCustomName())); containerMenu = new FurnaceMenu(inventory, furnace); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1022,14 +1005,13 @@ bool ServerPlayer::openFurnace(std::shared_ptr furnace) { bool ServerPlayer::openTrap(std::shared_ptr trap) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, - trap->GetType() == eTYPE_DROPPERTILEENTITY - ? ContainerOpenPacket::DROPPER - : ContainerOpenPacket::TRAP, - trap->getCustomName(), trap->getContainerSize(), - trap->hasCustomName())); + connection->send(std::make_shared( + containerCounter, + trap->GetType() == eTYPE_DROPPERTILEENTITY + ? ContainerOpenPacket::DROPPER + : ContainerOpenPacket::TRAP, + trap->getCustomName(), trap->getContainerSize(), + trap->hasCustomName())); containerMenu = new TrapMenu(inventory, trap); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1045,11 +1027,10 @@ bool ServerPlayer::openBrewingStand( std::shared_ptr brewingStand) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::BREWING_STAND, - brewingStand->getCustomName(), brewingStand->getContainerSize(), - brewingStand->hasCustomName())); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::BREWING_STAND, + brewingStand->getCustomName(), brewingStand->getContainerSize(), + brewingStand->hasCustomName())); containerMenu = new BrewingStandMenu(inventory, brewingStand); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1065,11 +1046,10 @@ bool ServerPlayer::openBrewingStand( bool ServerPlayer::openBeacon(std::shared_ptr beacon) { if (containerMenu == inventoryMenu) { nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::BEACON, - beacon->getCustomName(), beacon->getContainerSize(), - beacon->hasCustomName())); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::BEACON, + beacon->getCustomName(), beacon->getContainerSize(), + beacon->hasCustomName())); containerMenu = new BeaconMenu(inventory, beacon); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1091,11 +1071,10 @@ bool ServerPlayer::openTrading(std::shared_ptr traderTarget, std::shared_ptr container = ((MerchantMenu*)containerMenu)->getTradeContainer(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::TRADER_NPC, - name.empty() ? L"" : name, container->getContainerSize(), - !name.empty())); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::TRADER_NPC, + name.empty() ? L"" : name, container->getContainerSize(), + !name.empty())); MerchantRecipeList* offers = traderTarget->getOffers( std::dynamic_pointer_cast(shared_from_this())); @@ -1126,11 +1105,10 @@ bool ServerPlayer::openHorseInventory(std::shared_ptr horse, closeContainer(); } nextContainerCounter(); - connection->send( - std::make_shared( - containerCounter, ContainerOpenPacket::HORSE, - horse->getCustomName(), container->getContainerSize(), - container->hasCustomName(), horse->entityId)); + connection->send(std::make_shared( + containerCounter, ContainerOpenPacket::HORSE, horse->getCustomName(), + container->getContainerSize(), container->hasCustomName(), + horse->entityId)); containerMenu = new HorseInventoryMenu(inventory, container, horse); containerMenu->containerId = containerCounter; containerMenu->addSlotListener(this); @@ -1250,23 +1228,19 @@ void ServerPlayer::displayClientMessage(int messageId) { switch (messageId) { case IDS_TILE_BED_OCCUPIED: messageType = ChatPacket::e_ChatBedOccupied; - connection->send( - std::make_shared(L"", messageType)); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NO_SLEEP: messageType = ChatPacket::e_ChatBedNoSleep; - connection->send( - std::make_shared(L"", messageType)); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NOT_VALID: messageType = ChatPacket::e_ChatBedNotValid; - connection->send( - std::make_shared(L"", messageType)); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_NOTSAFE: messageType = ChatPacket::e_ChatBedNotSafe; - connection->send( - std::make_shared(L"", messageType)); + connection->send(std::make_shared(L"", messageType)); break; case IDS_TILE_BED_PLAYERSLEEP: messageType = ChatPacket::e_ChatBedPlayerSleep; @@ -1276,9 +1250,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() != player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatBedPlayerSleep)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatBedPlayerSleep)); } else { player->connection->send(std::shared_ptr( new ChatPacket(name, ChatPacket::e_ChatBedMeSleep))); @@ -1292,9 +1265,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() != player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerEnteredEnd)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerEnteredEnd)); } } break; @@ -1311,8 +1283,7 @@ void ServerPlayer::displayClientMessage(int messageId) { break; case IDS_TILE_BED_MESLEEP: messageType = ChatPacket::e_ChatBedMeSleep; - connection->send( - std::make_shared(L"", messageType)); + connection->send(std::make_shared(L"", messageType)); break; case IDS_MAX_PIGS_SHEEP_COWS_CATS_SPAWNED: @@ -1321,9 +1292,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxPigsSheepCows)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxPigsSheepCows)); } } break; @@ -1333,9 +1303,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxChickens)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxChickens)); } } break; @@ -1345,9 +1314,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxSquid)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxSquid)); } } break; @@ -1368,9 +1336,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxWolves)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxWolves)); } } break; @@ -1380,9 +1347,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxMooshrooms)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxMooshrooms)); } } break; @@ -1392,9 +1358,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxEnemies)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxEnemies)); } } break; @@ -1405,9 +1370,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxVillagers)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxVillagers)); } } break; @@ -1417,10 +1381,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, - ChatPacket::e_ChatPlayerMaxBredPigsSheepCows)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxBredPigsSheepCows)); } } break; @@ -1430,9 +1392,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxBredChickens)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxBredChickens)); } } break; @@ -1442,9 +1403,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxBredMooshrooms)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxBredMooshrooms)); } } break; @@ -1455,9 +1415,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxBredWolves)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxBredWolves)); } } break; @@ -1468,9 +1427,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerCantShearMooshroom)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerCantShearMooshroom)); } } break; @@ -1481,9 +1439,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxHangingEntities)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxHangingEntities)); } } break; @@ -1493,10 +1450,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, - ChatPacket::e_ChatPlayerCantSpawnInPeaceful)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerCantSpawnInPeaceful)); } } break; @@ -1507,9 +1462,8 @@ void ServerPlayer::displayClientMessage(int messageId) { std::shared_ptr player = server->getPlayers()->players[i]; if (shared_from_this() == player) { - player->connection->send( - std::make_shared( - name, ChatPacket::e_ChatPlayerMaxBoats)); + player->connection->send(std::make_shared( + name, ChatPacket::e_ChatPlayerMaxBoats)); } } break; @@ -1583,8 +1537,8 @@ void ServerPlayer::teleportTo(double x, double y, double z) { void ServerPlayer::crit(std::shared_ptr entity) { getLevel()->getTracker()->broadcastAndSend( - shared_from_this(), std::make_shared( - entity, AnimatePacket::CRITICAL_HIT)); + shared_from_this(), + std::make_shared(entity, AnimatePacket::CRITICAL_HIT)); } void ServerPlayer::magicCrit(std::shared_ptr entity) { diff --git a/targets/minecraft/server/level/TrackedEntity.cpp b/targets/minecraft/server/level/TrackedEntity.cpp index 7aa61fea3..8cd885fce 100644 --- a/targets/minecraft/server/level/TrackedEntity.cpp +++ b/targets/minecraft/server/level/TrackedEntity.cpp @@ -344,9 +344,8 @@ void TrackedEntity::tick(EntityTracker* tracker, abs(xRotn - xRotp) >= TOLERANCE_LEVEL; if (rot) { // 4J: Changed this to use deltas - broadcast( - std::make_shared( - e->entityId, (uint8_t)yRota, (uint8_t)xRota)); + broadcast(std::make_shared( + e->entityId, (uint8_t)yRota, (uint8_t)xRota)); yRotp = yRotn; xRotp = xRotn; } @@ -611,9 +610,8 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker, // 4J Stu brought forward to fix when Item Frames if (!e->getEntityData()->isEmpty() && !isAddMobPacket) { - sp->connection->send( - std::make_shared( - e->entityId, e->getEntityData(), true)); + sp->connection->send(std::make_shared( + e->entityId, e->getEntityData(), true)); } if (e->instanceof(eTYPE_LIVINGENTITY)) { @@ -637,16 +635,14 @@ void TrackedEntity::updatePlayer(EntityTracker* tracker, } if (e->riding != nullptr) { - sp->connection->send( - std::make_shared( - SetEntityLinkPacket::RIDING, e, e->riding)); + sp->connection->send(std::make_shared( + SetEntityLinkPacket::RIDING, e, e->riding)); } if (e->instanceof(eTYPE_MOB) && std::dynamic_pointer_cast(e)->getLeashHolder() != nullptr) { - sp->connection->send( - std::make_shared( - SetEntityLinkPacket::LEASH, e, - std::dynamic_pointer_cast(e)->getLeashHolder())); + sp->connection->send(std::make_shared( + SetEntityLinkPacket::LEASH, e, + std::dynamic_pointer_cast(e)->getLeashHolder())); } if (e->instanceof(eTYPE_LIVINGENTITY)) { @@ -730,8 +726,8 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { if (e->instanceof(eTYPE_ITEMENTITY)) { std::shared_ptr packet = - std::make_shared( - e, AddEntityPacket::ITEM, 1, yRotp, xRotp, xp, yp, zp); + std::make_shared(e, AddEntityPacket::ITEM, 1, + yRotp, xRotp, xp, yp, zp); return packet; } else if (e->instanceof(eTYPE_SERVERPLAYER)) { std::shared_ptr player = @@ -755,8 +751,8 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { new AddEntityPacket(e, AddEntityPacket::MINECART, minecart->getType(), yRotp, xRotp, xp, yp, zp)); } else if (e->instanceof(eTYPE_BOAT)) { - return std::make_shared( - e, AddEntityPacket::BOAT, yRotp, xRotp, xp, yp, zp); + return std::make_shared(e, AddEntityPacket::BOAT, + yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ENDERDRAGON)) { yHeadRotp = std::floor(e->getYHeadRot() * 256 / 360); return std::shared_ptr( @@ -777,8 +773,8 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { owner != nullptr ? owner->entityId : e->entityId, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_SNOWBALL)) { - return std::make_shared( - e, AddEntityPacket::SNOWBALL, yRotp, xRotp, xp, yp, zp); + return std::make_shared(e, AddEntityPacket::SNOWBALL, + yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_THROWNPOTION)) { return std::make_shared( e, AddEntityPacket::THROWN_POTION, @@ -794,8 +790,8 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { return std::make_shared( e, AddEntityPacket::EYEOFENDERSIGNAL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FIREWORKS_ROCKET)) { - return std::make_shared( - e, AddEntityPacket::FIREWORKS, yRotp, xRotp, xp, yp, zp); + return std::make_shared(e, AddEntityPacket::FIREWORKS, + yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FIREBALL)) { eINSTANCEOF classType = e->GetType(); int type = AddEntityPacket::FIREBALL; @@ -821,20 +817,20 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { aep->za = (int)(fb->zPower * 8000); return aep; } else if (e->instanceof(eTYPE_THROWNEGG)) { - return std::make_shared( - e, AddEntityPacket::EGG, yRotp, xRotp, xp, yp, zp); + return std::make_shared(e, AddEntityPacket::EGG, yRotp, + xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_PRIMEDTNT)) { - return std::make_shared( - e, AddEntityPacket::PRIMED_TNT, yRotp, xRotp, xp, yp, zp); + return std::make_shared(e, AddEntityPacket::PRIMED_TNT, + yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_ENDER_CRYSTAL)) { return std::make_shared( e, AddEntityPacket::ENDER_CRYSTAL, yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_FALLINGTILE)) { std::shared_ptr ft = std::dynamic_pointer_cast(e); - return std::make_shared( - e, AddEntityPacket::FALLING, ft->tile | (ft->data << 16), yRotp, - xRotp, xp, yp, zp); + return std::make_shared(e, AddEntityPacket::FALLING, + ft->tile | (ft->data << 16), + yRotp, xRotp, xp, yp, zp); } else if (e->instanceof(eTYPE_PAINTING)) { return std::shared_ptr( new AddPaintingPacket(std::dynamic_pointer_cast(e))); @@ -861,8 +857,8 @@ std::shared_ptr TrackedEntity::getAddEntityPacket() { std::shared_ptr knot = std::dynamic_pointer_cast(e); std::shared_ptr packet = - std::make_shared( - e, AddEntityPacket::LEASH_KNOT, yRotp, xRotp, xp, yp, zp); + std::make_shared(e, AddEntityPacket::LEASH_KNOT, + yRotp, xRotp, xp, yp, zp); packet->x = std::floor((float)knot->xTile * 32); packet->y = std::floor((float)knot->yTile * 32); packet->z = std::floor((float)knot->zTile * 32); diff --git a/targets/minecraft/server/network/PendingConnection.cpp b/targets/minecraft/server/network/PendingConnection.cpp index d8b6b97bd..9ec7c5e8b 100644 --- a/targets/minecraft/server/network/PendingConnection.cpp +++ b/targets/minecraft/server/network/PendingConnection.cpp @@ -65,8 +65,7 @@ void PendingConnection::disconnect(DisconnectPacket::eDisconnectReason reason) { fprintf(stderr, "[PENDING] disconnect called with reason=%d at tick=%d\n", reason, _tick); app.DebugPrintf("Pending connection disconnect: %d\n", reason); - connection->send( - std::make_shared(reason)); + connection->send(std::make_shared(reason)); connection->sendAndQuit(); done = true; // } catch (Exception e) { diff --git a/targets/minecraft/server/network/PlayerConnection.cpp b/targets/minecraft/server/network/PlayerConnection.cpp index 5ee5cbab8..022984d1e 100644 --- a/targets/minecraft/server/network/PlayerConnection.cpp +++ b/targets/minecraft/server/network/PlayerConnection.cpp @@ -190,9 +190,8 @@ void PlayerConnection::disconnect(DisconnectPacket::eDisconnectReason reason) { // server->players->broadcastAll( std::shared_ptr( new // ChatPacket(L"§e" + player->name + L" left the game.") ) ); if (getWasKicked()) { - server->getPlayers()->broadcastAll( - std::make_shared( - player->name, ChatPacket::e_ChatPlayerKickedFromGame)); + server->getPlayers()->broadcastAll(std::make_shared( + player->name, ChatPacket::e_ChatPlayerKickedFromGame)); } else { server->getPlayers()->broadcastAll(std::shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame))); @@ -294,7 +293,8 @@ void PlayerConnection::handleMovePlayer( // stance: " + yd); return; } - if (std::abs(packet->x) > 32000000 || std::abs(packet->z) > 32000000) { + if (std::abs(packet->x) > 32000000 || + std::abs(packet->z) > 32000000) { disconnect(DisconnectPacket::eDisconnect_IllegalPosition); return; } @@ -435,9 +435,8 @@ void PlayerConnection::teleport(double x, double y, double z, float yRot, // end This is different to the way that height is sent back to the server, // where it represents the bottom of the player bounding volume if (sendPacket) - player->connection->send( - std::make_shared( - x, y + 1.62f, y, z, yRot, xRot, false, false)); + player->connection->send(std::make_shared( + x, y + 1.62f, y, z, yRot, xRot, false, false)); } void PlayerConnection::handlePlayerAction( @@ -623,9 +622,8 @@ void PlayerConnection::onDisconnect(DisconnectPacket::eDisconnectReason reason, // server->players->broadcastAll( std::shared_ptr( new // ChatPacket(L"§e" + player->name + L" left the game.") ) ); if (getWasKicked()) { - server->getPlayers()->broadcastAll( - std::make_shared( - player->name, ChatPacket::e_ChatPlayerKickedFromGame)); + server->getPlayers()->broadcastAll(std::make_shared( + player->name, ChatPacket::e_ChatPlayerKickedFromGame)); } else { server->getPlayers()->broadcastAll(std::shared_ptr( new ChatPacket(player->name, ChatPacket::e_ChatPlayerLeftGame))); @@ -1202,9 +1200,8 @@ void PlayerConnection::handleContainerClick( if (ItemInstance::matches(packet->item, clicked)) { // Yep, you sure did click what you claimed to click! - player->connection->send( - std::make_shared( - packet->containerId, packet->uid, true)); + player->connection->send(std::make_shared( + packet->containerId, packet->uid, true)); player->ignoreSlotUpdateHack = true; player->containerMenu->broadcastChanges(); player->broadcastCarriedItem(); @@ -1212,9 +1209,8 @@ void PlayerConnection::handleContainerClick( } else { // No, you clicked the wrong thing! expectedAcks[player->containerMenu->containerId] = packet->uid; - player->connection->send( - std::make_shared( - packet->containerId, packet->uid, false)); + player->connection->send(std::make_shared( + packet->containerId, packet->uid, false)); player->containerMenu->setSynched(player, false); std::vector > items; @@ -1269,8 +1265,7 @@ void PlayerConnection::handleSetCreativeModeSlot( swprintf(buf, 64, L"map_%d", item->getAuxValue()); std::wstring id = std::wstring(buf); if (data == nullptr) { - data = - std::make_shared(id); + data = std::make_shared(id); } player->level->setSavedData(id, (std::shared_ptr)data); @@ -1743,10 +1738,9 @@ void PlayerConnection::handleCraftItem( if (ingItemInst != nullptr) { if (ingItemInst->getItem()->hasCraftingRemainingItem()) { // replace item with remaining result - player->inventory->add( - std::make_shared( - ingItemInst->getItem() - ->getCraftingRemainingItem())); + player->inventory->add(std::make_shared( + ingItemInst->getItem() + ->getCraftingRemainingItem())); } } } diff --git a/targets/minecraft/stats/CommonStats.cpp b/targets/minecraft/stats/CommonStats.cpp index 1bad506e2..4df58dea4 100644 --- a/targets/minecraft/stats/CommonStats.cpp +++ b/targets/minecraft/stats/CommonStats.cpp @@ -303,27 +303,33 @@ std::vector CommonStats::getParam_pigOneM(int distance) { return makeParam(distance); } -std::vector CommonStats::getParam_blocksMined(int id, int data, int count) { +std::vector CommonStats::getParam_blocksMined(int id, int data, + int count) { return makeParam(count); } -std::vector CommonStats::getParam_itemsCollected(int id, int aux, int count) { +std::vector CommonStats::getParam_itemsCollected(int id, int aux, + int count) { return makeParam(count); } -std::vector CommonStats::getParam_itemsCrafted(int id, int aux, int count) { +std::vector CommonStats::getParam_itemsCrafted(int id, int aux, + int count) { return makeParam(count); } -std::vector CommonStats::getParam_itemsSmelted(int id, int aux, int count) { +std::vector CommonStats::getParam_itemsSmelted(int id, int aux, + int count) { return makeParam(count); } -std::vector CommonStats::getParam_itemsUsed(int id, int aux, int count) { +std::vector CommonStats::getParam_itemsUsed(int id, int aux, + int count) { return makeParam(count); } -std::vector CommonStats::getParam_itemsBought(int id, int aux, int count) { +std::vector CommonStats::getParam_itemsBought(int id, int aux, + int count) { return makeParam(count); } diff --git a/targets/minecraft/stats/CommonStats.h b/targets/minecraft/stats/CommonStats.h index c47e5849f..41adbb343 100644 --- a/targets/minecraft/stats/CommonStats.h +++ b/targets/minecraft/stats/CommonStats.h @@ -66,12 +66,17 @@ protected: virtual std::vector getParam_boatOneM(int distance); virtual std::vector getParam_pigOneM(int distance); - virtual std::vector getParam_blocksMined(int id, int data, int count); - virtual std::vector getParam_itemsCollected(int id, int aux, int count); - virtual std::vector getParam_itemsCrafted(int id, int aux, int count); - virtual std::vector getParam_itemsSmelted(int id, int aux, int count); + virtual std::vector getParam_blocksMined(int id, int data, + int count); + virtual std::vector getParam_itemsCollected(int id, int aux, + int count); + virtual std::vector getParam_itemsCrafted(int id, int aux, + int count); + virtual std::vector getParam_itemsSmelted(int id, int aux, + int count); virtual std::vector getParam_itemsUsed(int id, int aux, int count); - virtual std::vector getParam_itemsBought(int id, int aux, int count); + virtual std::vector getParam_itemsBought(int id, int aux, + int count); virtual std::vector getParam_time(int timediff); diff --git a/targets/minecraft/stats/DurangoStats.h b/targets/minecraft/stats/DurangoStats.h index 3cc42142d..855abc784 100644 --- a/targets/minecraft/stats/DurangoStats.h +++ b/targets/minecraft/stats/DurangoStats.h @@ -43,8 +43,9 @@ public: virtual void handleParamBlob(std::shared_ptr plr, std::vector& param); - static std::vector createParamBlob(eAcquisitionMethod methodId, int itemId, - int itemAux, int itemCount); + static std::vector createParamBlob(eAcquisitionMethod methodId, + int itemId, int itemAux, + int itemCount); }; class DsMobKilled : public Stat { @@ -63,8 +64,8 @@ public: virtual void handleParamBlob(std::shared_ptr plr, std::vector& param); static std::vector createParamBlob(std::shared_ptr plr, - std::shared_ptr mob, - DamageSource* dmgSrc); + std::shared_ptr mob, + DamageSource* dmgSrc); }; class DsMobInteract : public Stat { @@ -88,7 +89,8 @@ public: } Param; virtual void handleParamBlob(std::shared_ptr plr, std::vector& param); - static std::vector createParamBlob(eInteract interactionId, int entityId); + static std::vector createParamBlob(eInteract interactionId, + int entityId); }; class DsTravel : public Stat { @@ -137,8 +139,8 @@ public: } Param; virtual void handleParamBlob(std::shared_ptr plr, std::vector& paramBlob); - static std::vector createParamBlob(int itemId, int aux, int count, int health, - int hunger); + static std::vector createParamBlob(int itemId, int aux, int count, + int health, int hunger); }; class DsAchievement : public Stat { @@ -276,17 +278,22 @@ protected: virtual std::vector getParam_cowsMilked(); - virtual std::vector getParam_blocksPlaced(int blockId, int data, int count); - virtual std::vector getParam_blocksMined(int blockId, int data, int count); - virtual std::vector getParam_itemsCollected(int id, int aux, int count); - virtual std::vector getParam_itemsCrafted(int id, int aux, int count); - virtual std::vector getParam_itemsUsed(std::shared_ptr plr, - std::shared_ptr itm); - virtual std::vector getParam_itemsBought(int id, int aux, int count); + virtual std::vector getParam_blocksPlaced(int blockId, int data, + int count); + virtual std::vector getParam_blocksMined(int blockId, int data, + int count); + virtual std::vector getParam_itemsCollected(int id, int aux, + int count); + virtual std::vector getParam_itemsCrafted(int id, int aux, + int count); + virtual std::vector getParam_itemsUsed( + std::shared_ptr plr, std::shared_ptr itm); + virtual std::vector getParam_itemsBought(int id, int aux, + int count); virtual std::vector getParam_mobKill(std::shared_ptr plr, - std::shared_ptr mob, - DamageSource* dmgSrc); + std::shared_ptr mob, + DamageSource* dmgSrc); virtual std::vector getParam_breedEntity(eINSTANCEOF entityId); virtual std::vector getParam_tamedEntity(eINSTANCEOF entityId); diff --git a/targets/minecraft/stats/GenericStats.cpp b/targets/minecraft/stats/GenericStats.cpp index 834f247f5..b65b23dba 100644 --- a/targets/minecraft/stats/GenericStats.cpp +++ b/targets/minecraft/stats/GenericStats.cpp @@ -428,40 +428,48 @@ std::vector GenericStats::getParam_pigOneM(int distance) { return getParam_noArgs(); // Really just a count on most platforms. } -std::vector GenericStats::getParam_cowsMilked() { return getParam_noArgs(); } +std::vector GenericStats::getParam_cowsMilked() { + return getParam_noArgs(); +} -std::vector GenericStats::getParam_blocksPlaced(int id, int data, int count) { +std::vector GenericStats::getParam_blocksPlaced(int id, int data, + int count) { return getParam_noArgs(); // Really just a count on most platforms. } -std::vector GenericStats::getParam_blocksMined(int id, int data, int count) { +std::vector GenericStats::getParam_blocksMined(int id, int data, + int count) { return getParam_noArgs(); // Really just a count on most platforms. } -std::vector GenericStats::getParam_itemsCollected(int id, int aux, int count) { +std::vector GenericStats::getParam_itemsCollected(int id, int aux, + int count) { return getParam_noArgs(); // Really just a count on most platforms. } -std::vector GenericStats::getParam_itemsCrafted(int id, int aux, int count) { +std::vector GenericStats::getParam_itemsCrafted(int id, int aux, + int count) { return getParam_noArgs(); // Really just a count on most platforms. } -std::vector GenericStats::getParam_itemsSmelted(int id, int aux, int count) { +std::vector GenericStats::getParam_itemsSmelted(int id, int aux, + int count) { return this->getParam_itemsCrafted(id, aux, count); } -std::vector GenericStats::getParam_itemsUsed(std::shared_ptr plr, - std::shared_ptr itm) { +std::vector GenericStats::getParam_itemsUsed( + std::shared_ptr plr, std::shared_ptr itm) { return getParam_noArgs(); // Really just a count on most platforms. } -std::vector GenericStats::getParam_itemsBought(int id, int aux, int count) { +std::vector GenericStats::getParam_itemsBought(int id, int aux, + int count) { return getParam_noArgs(); } std::vector GenericStats::getParam_mobKill(std::shared_ptr plr, - std::shared_ptr mob, - DamageSource* dmgSrc) { + std::shared_ptr mob, + DamageSource* dmgSrc) { return getParam_noArgs(); // Really just a count on most platforms. } @@ -477,11 +485,13 @@ std::vector GenericStats::getParam_curedEntity(eINSTANCEOF entityId) { return getParam_noArgs(); // Really just a count on most platforms. } -std::vector GenericStats::getParam_craftedEntity(eINSTANCEOF entityId) { +std::vector GenericStats::getParam_craftedEntity( + eINSTANCEOF entityId) { return getParam_noArgs(); // Really just a count on most platforms. } -std::vector GenericStats::getParam_shearedEntity(eINSTANCEOF entityId) { +std::vector GenericStats::getParam_shearedEntity( + eINSTANCEOF entityId) { return getParam_noArgs(); // Really just a count on most platforms. } @@ -513,7 +523,8 @@ std::vector GenericStats::getParam_openInventory(int menuId) { return getParam_achievement(eAward_TakingInventory); } -std::vector GenericStats::getParam_chestfulOfCobblestone(int cobbleStone) { +std::vector GenericStats::getParam_chestfulOfCobblestone( + int cobbleStone) { #if defined(_EXTENDED_ACHIEVEMENTS) return getParam_achievement(eAward_chestfulOfCobblestone); #else @@ -565,41 +576,47 @@ std::vector GenericStats::param_cowsMilked() { return instance->getParam_cowsMilked(); } -std::vector GenericStats::param_blocksPlaced(int id, int data, int count) { +std::vector GenericStats::param_blocksPlaced(int id, int data, + int count) { return instance->getParam_blocksPlaced(id, data, count); } -std::vector GenericStats::param_blocksMined(int id, int data, int count) { +std::vector GenericStats::param_blocksMined(int id, int data, + int count) { return instance->getParam_blocksMined(id, data, count); } -std::vector GenericStats::param_itemsCollected(int id, int aux, int count) { +std::vector GenericStats::param_itemsCollected(int id, int aux, + int count) { return instance->getParam_itemsCollected(id, aux, count); } -std::vector GenericStats::param_itemsCrafted(int id, int aux, int count) { +std::vector GenericStats::param_itemsCrafted(int id, int aux, + int count) { return instance->getParam_itemsCrafted(id, aux, count); } -std::vector GenericStats::param_itemsSmelted(int id, int aux, int count) { +std::vector GenericStats::param_itemsSmelted(int id, int aux, + int count) { return instance->getParam_itemsSmelted(id, aux, count); } -std::vector GenericStats::param_itemsUsed(std::shared_ptr plr, - std::shared_ptr itm) { +std::vector GenericStats::param_itemsUsed( + std::shared_ptr plr, std::shared_ptr itm) { if ((plr != nullptr) && (itm != nullptr)) return instance->getParam_itemsUsed(plr, itm); else return instance->getParam_noArgs(); } -std::vector GenericStats::param_itemsBought(int id, int aux, int count) { +std::vector GenericStats::param_itemsBought(int id, int aux, + int count) { return instance->getParam_itemsBought(id, aux, count); } std::vector GenericStats::param_mobKill(std::shared_ptr plr, - std::shared_ptr mob, - DamageSource* dmgSrc) { + std::shared_ptr mob, + DamageSource* dmgSrc) { if ((plr != nullptr) && (mob != nullptr)) return instance->getParam_mobKill(plr, mob, dmgSrc); else @@ -638,7 +655,9 @@ std::vector GenericStats::param_enteredBiome(int biomeId) { return instance->getParam_enteredBiome(biomeId); } -std::vector GenericStats::param_noArgs() { return instance->getParam_noArgs(); } +std::vector GenericStats::param_noArgs() { + return instance->getParam_noArgs(); +} std::vector GenericStats::param_openInventory() { return instance->getParam_achievement(eAward_TakingInventory); @@ -892,7 +911,8 @@ std::vector GenericStats::param_stayinFrosty() { #endif } -std::vector GenericStats::param_chestfulOfCobblestone(int cobbleStone) { +std::vector GenericStats::param_chestfulOfCobblestone( + int cobbleStone) { return instance->getParam_chestfulOfCobblestone(cobbleStone); } diff --git a/targets/minecraft/stats/GenericStats.h b/targets/minecraft/stats/GenericStats.h index 7e718e9e5..f606ceef6 100644 --- a/targets/minecraft/stats/GenericStats.h +++ b/targets/minecraft/stats/GenericStats.h @@ -210,16 +210,17 @@ public: static std::vector param_blocksPlaced(int id, int data, int count); static std::vector param_blocksMined(int id, int data, int count); - static std::vector param_itemsCollected(int id, int aux, int count); + static std::vector param_itemsCollected(int id, int aux, + int count); static std::vector param_itemsCrafted(int id, int aux, int count); static std::vector param_itemsSmelted(int id, int aux, int cound); - static std::vector param_itemsUsed(std::shared_ptr plr, - std::shared_ptr itm); + static std::vector param_itemsUsed( + std::shared_ptr plr, std::shared_ptr itm); static std::vector param_itemsBought(int id, int aux, int count); static std::vector param_mobKill(std::shared_ptr plr, - std::shared_ptr mob, - DamageSource* dmgSrc); + std::shared_ptr mob, + DamageSource* dmgSrc); static std::vector param_breedEntity(eINSTANCEOF mobType); static std::vector param_tamedEntity(eINSTANCEOF mobType); @@ -369,18 +370,24 @@ protected: virtual std::vector getParam_cowsMilked(); - virtual std::vector getParam_blocksPlaced(int id, int data, int count); - virtual std::vector getParam_blocksMined(int id, int data, int count); - virtual std::vector getParam_itemsCollected(int id, int aux, int count); - virtual std::vector getParam_itemsCrafted(int id, int aux, int count); - virtual std::vector getParam_itemsSmelted(int id, int aux, int count); - virtual std::vector getParam_itemsUsed(std::shared_ptr plr, - std::shared_ptr itm); - virtual std::vector getParam_itemsBought(int id, int aux, int count); + virtual std::vector getParam_blocksPlaced(int id, int data, + int count); + virtual std::vector getParam_blocksMined(int id, int data, + int count); + virtual std::vector getParam_itemsCollected(int id, int aux, + int count); + virtual std::vector getParam_itemsCrafted(int id, int aux, + int count); + virtual std::vector getParam_itemsSmelted(int id, int aux, + int count); + virtual std::vector getParam_itemsUsed( + std::shared_ptr plr, std::shared_ptr itm); + virtual std::vector getParam_itemsBought(int id, int aux, + int count); virtual std::vector getParam_mobKill(std::shared_ptr plr, - std::shared_ptr mob, - DamageSource* dmgSrc); + std::shared_ptr mob, + DamageSource* dmgSrc); virtual std::vector getParam_breedEntity(eINSTANCEOF entityId); virtual std::vector getParam_tamedEntity(eINSTANCEOF entityId); @@ -398,7 +405,8 @@ protected: virtual std::vector getParam_onARail(int distance); virtual std::vector getParam_overkill(int damage); virtual std::vector getParam_openInventory(int menuId); - virtual std::vector getParam_chestfulOfCobblestone(int cobbleStone); + virtual std::vector getParam_chestfulOfCobblestone( + int cobbleStone); virtual std::vector getParam_musicToMyEars(int recordId); virtual std::vector getParam_noArgs(); diff --git a/targets/minecraft/stats/StatsCounter.cpp b/targets/minecraft/stats/StatsCounter.cpp index 9de9e2e8b..3ee21d97b 100644 --- a/targets/minecraft/stats/StatsCounter.cpp +++ b/targets/minecraft/stats/StatsCounter.cpp @@ -243,7 +243,6 @@ void StatsCounter::save(int player, bool force) { } } - saveCounter = SAVE_DELAY; } diff --git a/targets/minecraft/util/Mth.h b/targets/minecraft/util/Mth.h index a6d2e6a81..32363dd44 100644 --- a/targets/minecraft/util/Mth.h +++ b/targets/minecraft/util/Mth.h @@ -26,9 +26,7 @@ public: static int floor(double v) { return (int)::floor(v); } static int64_t lfloor(double v) { return (int64_t)::floor(v); } - static int fastFloor(double x) { - return (int)(x + 1024.0) - 1024; - } + static int fastFloor(double x) { return (int)(x + 1024.0) - 1024; } static float abs(float v) { return v >= 0.0f ? v : -v; } static int abs(int v) { return v >= 0 ? v : -v; } diff --git a/targets/minecraft/util/WeighedRandom.cpp b/targets/minecraft/util/WeighedRandom.cpp index 7c39e1efa..4ab9f071a 100644 --- a/targets/minecraft/util/WeighedRandom.cpp +++ b/targets/minecraft/util/WeighedRandom.cpp @@ -37,7 +37,8 @@ WeighedRandomItem* WeighedRandom::getRandomItem( return getRandomItem(random, items, getTotalWeight(items)); } -int WeighedRandom::getTotalWeight(const std::vector& items) { +int WeighedRandom::getTotalWeight( + const std::vector& items) { int totalWeight = 0; for (unsigned int i = 0; i < items.size(); i++) { totalWeight += items[i]->randomWeight; @@ -45,9 +46,9 @@ int WeighedRandom::getTotalWeight(const std::vector& items) return totalWeight; } -WeighedRandomItem* WeighedRandom::getRandomItem(Random* random, - const std::vector& items, - int totalWeight) { +WeighedRandomItem* WeighedRandom::getRandomItem( + Random* random, const std::vector& items, + int totalWeight) { if (totalWeight <= 0) { __debugbreak(); } @@ -62,7 +63,7 @@ WeighedRandomItem* WeighedRandom::getRandomItem(Random* random, return nullptr; } -WeighedRandomItem* WeighedRandom::getRandomItem(Random* random, - const std::vector& items) { +WeighedRandomItem* WeighedRandom::getRandomItem( + Random* random, const std::vector& items) { return getRandomItem(random, items, getTotalWeight(items)); } \ No newline at end of file diff --git a/targets/minecraft/util/WeighedRandom.h b/targets/minecraft/util/WeighedRandom.h index 09b0fa350..b3247bd22 100644 --- a/targets/minecraft/util/WeighedRandom.h +++ b/targets/minecraft/util/WeighedRandom.h @@ -27,9 +27,9 @@ public: static WeighedRandomItem* getRandomItem( Random* random, std::vector* items); static int getTotalWeight(const std::vector& items); - static WeighedRandomItem* getRandomItem(Random* random, - const std::vector& items, - int totalWeight); - static WeighedRandomItem* getRandomItem(Random* random, - const std::vector& items); + static WeighedRandomItem* getRandomItem( + Random* random, const std::vector& items, + int totalWeight); + static WeighedRandomItem* getRandomItem( + Random* random, const std::vector& items); }; diff --git a/targets/minecraft/util/WeighedTreasure.cpp b/targets/minecraft/util/WeighedTreasure.cpp index 8fcbb7c9e..f2debd5e1 100644 --- a/targets/minecraft/util/WeighedTreasure.cpp +++ b/targets/minecraft/util/WeighedTreasure.cpp @@ -7,8 +7,7 @@ WeighedTreasure::WeighedTreasure(int itemId, int auxValue, int minCount, int maxCount, int weight) : WeighedRandomItem(weight) { - this->item = - std::make_shared(itemId, 1, auxValue); + this->item = std::make_shared(itemId, 1, auxValue); this->minCount = minCount; this->maxCount = maxCount; } @@ -21,7 +20,8 @@ WeighedTreasure::WeighedTreasure(std::shared_ptr item, this->maxCount = maxCount; } -void WeighedTreasure::addChestItems(Random* random, const std::vector& items, +void WeighedTreasure::addChestItems(Random* random, + const std::vector& items, std::shared_ptr dest, int numRolls) { for (int r = 0; r < numRolls; r++) { @@ -73,8 +73,8 @@ void WeighedTreasure::addDispenserItems( } } -std::vector WeighedTreasure::addToTreasure(std::vector& items, - WeighedTreasure* extra) { +std::vector WeighedTreasure::addToTreasure( + std::vector& items, WeighedTreasure* extra) { std::vector result(items.size() + 1); int i = 0; diff --git a/targets/minecraft/util/WeighedTreasure.h b/targets/minecraft/util/WeighedTreasure.h index 75e455ff4..f8a8cacb4 100644 --- a/targets/minecraft/util/WeighedTreasure.h +++ b/targets/minecraft/util/WeighedTreasure.h @@ -24,11 +24,13 @@ public: WeighedTreasure(std::shared_ptr item, int minCount, int maxCount, int weight); - static void addChestItems(Random* random, const std::vector& items, + static void addChestItems(Random* random, + const std::vector& items, std::shared_ptr dest, int numRolls); - static void addDispenserItems(Random* random, const std::vector& items, + static void addDispenserItems(Random* random, + const std::vector& items, std::shared_ptr dest, int numRolls); - static std::vector addToTreasure(std::vector& items, - WeighedTreasure* extra); + static std::vector addToTreasure( + std::vector& items, WeighedTreasure* extra); }; \ No newline at end of file diff --git a/targets/minecraft/world/damageSource/EntityDamageSource.cpp b/targets/minecraft/world/damageSource/EntityDamageSource.cpp index 3c4259e10..ed62be972 100644 --- a/targets/minecraft/world/damageSource/EntityDamageSource.cpp +++ b/targets/minecraft/world/damageSource/EntityDamageSource.cpp @@ -49,12 +49,12 @@ std::shared_ptr EntityDamageSource::getDeathMessagePacket( } if ((held != nullptr) && held->hasCustomHoverName()) { - return std::make_shared( - player->getNetworkName(), m_msgWithItemId, entity->GetType(), - additional, held->getHoverName()); + return std::make_shared(player->getNetworkName(), + m_msgWithItemId, entity->GetType(), + additional, held->getHoverName()); } else { - return std::make_shared( - player->getNetworkName(), m_msgId, entity->GetType(), additional); + return std::make_shared(player->getNetworkName(), m_msgId, + entity->GetType(), additional); } } diff --git a/targets/minecraft/world/damageSource/IndirectEntityDamageSource.cpp b/targets/minecraft/world/damageSource/IndirectEntityDamageSource.cpp index 60946b20e..f3e639002 100644 --- a/targets/minecraft/world/damageSource/IndirectEntityDamageSource.cpp +++ b/targets/minecraft/world/damageSource/IndirectEntityDamageSource.cpp @@ -62,8 +62,8 @@ std::shared_ptr IndirectEntityDamageSource::getDeathMessagePacket( new ChatPacket(player->getNetworkName(), m_msgWithItemId, type, additional, held->getHoverName())); } else { - return std::make_shared( - player->getNetworkName(), m_msgId, type, additional); + return std::make_shared(player->getNetworkName(), m_msgId, + type, additional); } } diff --git a/targets/minecraft/world/entity/Entity.cpp b/targets/minecraft/world/entity/Entity.cpp index 614c717a2..6bd71a5c3 100644 --- a/targets/minecraft/world/entity/Entity.cpp +++ b/targets/minecraft/world/entity/Entity.cpp @@ -333,8 +333,7 @@ void Entity::_init(bool useSmallId, Level* level) { // values that need to be sent to clients in SMP if (useSmallId) { - entityData = - std::make_shared(); + entityData = std::make_shared(); } else { entityData = nullptr; } @@ -1405,9 +1404,8 @@ std::shared_ptr Entity::spawnAtLocation(int resource, int count) { std::shared_ptr Entity::spawnAtLocation(int resource, int count, float yOffs) { - return spawnAtLocation( - std::make_shared(resource, count, 0), - yOffs); + return spawnAtLocation(std::make_shared(resource, count, 0), + yOffs); } std::shared_ptr Entity::spawnAtLocation( @@ -1535,7 +1533,8 @@ void Entity::lerpTo(double x, double y, double z, float yRot, float xRot, // intersect the geometry they land in slightly. if (GetType() != eTYPE_ARROW) { AABB shrunk = bb.shrink(1 / 32.0, 0.0, 1 / 32.0); - std::vector* collisions = level->getCubes(shared_from_this(), &shrunk); + std::vector* collisions = + level->getCubes(shared_from_this(), &shrunk); if (!collisions->empty()) { double yTop = 0; auto itEnd = collisions->end(); @@ -1583,9 +1582,12 @@ void Entity::handleEntityEvent(uint8_t eventId) {} void Entity::animateHurt() {} -std::vector> Entity::getEquipmentSlots() // ItemInstance[] +std::vector> +Entity::getEquipmentSlots() // ItemInstance[] { - return std::vector>(); // Default ctor creates nullptr internal array + return std::vector>(); // Default ctor + // creates nullptr + // internal array } // 4J Stu - Brought forward change from 1.3 to fix #64688 - Customer @@ -1744,7 +1746,7 @@ std::wstring Entity::getAName() { #endif } -std::vector >* Entity::getSubEntities() { +std::vector>* Entity::getSubEntities() { return nullptr; } diff --git a/targets/minecraft/world/entity/Entity.h b/targets/minecraft/world/entity/Entity.h index 8aac3a923..4bdeb9d3b 100644 --- a/targets/minecraft/world/entity/Entity.h +++ b/targets/minecraft/world/entity/Entity.h @@ -357,7 +357,8 @@ public: virtual void lerpMotion(double xd, double yd, double zd); virtual void handleEntityEvent(uint8_t eventId); virtual void animateHurt(); - virtual std::vector> getEquipmentSlots(); // ItemInstance[] + virtual std::vector> + getEquipmentSlots(); // ItemInstance[] virtual void setEquippedSlot( int slot, std::shared_ptr item); // 4J Stu - Brought forward change from 1.3 to fix @@ -443,7 +444,7 @@ public: bool isExtraWanderingEnabled(); int getWanderingQuadrant(); - virtual std::vector >* getSubEntities(); + virtual std::vector>* getSubEntities(); virtual bool is(std::shared_ptr other); virtual float getYHeadRot(); virtual void setYHeadRot(float yHeadRot); diff --git a/targets/minecraft/world/entity/ItemFrame.cpp b/targets/minecraft/world/entity/ItemFrame.cpp index 1c3bbed6b..c3673de5d 100644 --- a/targets/minecraft/world/entity/ItemFrame.cpp +++ b/targets/minecraft/world/entity/ItemFrame.cpp @@ -54,8 +54,7 @@ void ItemFrame::dropItem(std::shared_ptr causedBy) { } } - spawnAtLocation( - std::make_shared(Item::frame), 0); + spawnAtLocation(std::make_shared(Item::frame), 0); if ((item != nullptr) && (random->nextFloat() < dropChance)) { item = item->copy(); removeFramedMap(item); diff --git a/targets/minecraft/world/entity/LivingEntity.cpp b/targets/minecraft/world/entity/LivingEntity.cpp index e4246d1c9..419fb3b97 100644 --- a/targets/minecraft/world/entity/LivingEntity.cpp +++ b/targets/minecraft/world/entity/LivingEntity.cpp @@ -158,7 +158,6 @@ LivingEntity::~LivingEntity() { delete attributes; delete combatTracker; - } void LivingEntity::defineSynchedData() { @@ -1534,7 +1533,8 @@ void LivingEntity::aiStep() { // pop up the sides of walls, undersides of trees etc. AABB shrinkbb = bb.shrink(0.1, 0, 0.1); shrinkbb.y1 = shrinkbb.y0 + 0.1; - std::vector* collisions = level->getCubes(shared_from_this(), &shrinkbb); + std::vector* collisions = + level->getCubes(shared_from_this(), &shrinkbb); if (collisions->size() > 0) { double yTop = 0; auto itEnd = collisions->end(); @@ -1601,7 +1601,7 @@ void LivingEntity::newServerAiStep() {} void LivingEntity::pushEntities() { AABB grown = bb.grow(0.2, 0, 0.2); - std::vector >* entities = + std::vector>* entities = level->getEntities(shared_from_this(), &grown); if (entities != nullptr && !entities->empty()) { auto itEnd = entities->end(); diff --git a/targets/minecraft/world/entity/Mob.cpp b/targets/minecraft/world/entity/Mob.cpp index cc3b75aeb..f022f68c8 100644 --- a/targets/minecraft/world/entity/Mob.cpp +++ b/targets/minecraft/world/entity/Mob.cpp @@ -111,7 +111,6 @@ Mob::~Mob() { if (sensing != nullptr) delete sensing; if (leashInfoTag != nullptr) delete leashInfoTag; - } void Mob::registerAttributes() { @@ -319,7 +318,7 @@ void Mob::aiStep() { if (!level->isClientSide && canPickUpLoot() && !dead && level->getGameRules()->getBoolean(GameRules::RULE_MOBGRIEFING)) { AABB grown = bb.grow(1, 0, 1); - std::vector >* entities = + std::vector>* entities = level->getEntitiesOfClass(typeid(ItemEntity), &grown); for (auto it = entities->begin(); it != entities->end(); ++it) { std::shared_ptr entity = @@ -424,32 +423,30 @@ void Mob::checkDespawn() { } void Mob::newServerAiStep() { - noActionTime++; - checkDespawn(); - - sensing->tick(); - - targetSelector.tick(); - - goalSelector.tick(); - - navigation->tick(); - - serverAiMobStep(); - - moveControl->tick(); - - lookControl->tick(); - - jumpControl->tick(); - + noActionTime++; + checkDespawn(); + + sensing->tick(); + + targetSelector.tick(); + + goalSelector.tick(); + + navigation->tick(); + + serverAiMobStep(); + + moveControl->tick(); + + lookControl->tick(); + + jumpControl->tick(); + // Consider this for extra strolling if it is protected against despawning. // We aren't interested in ones that aren't protected as the whole point of // this extra wandering is to potentially transition from protected to not // protected. - considerForExtraWandering(isDespawnProtected()); - - + considerForExtraWandering(isDespawnProtected()); } void Mob::serverAiStep() { @@ -567,7 +564,9 @@ void Mob::setEquippedSlot(int slot, std::shared_ptr item) { equipment[slot] = item; } -std::vector> Mob::getEquipmentSlots() { return equipment; } +std::vector> Mob::getEquipmentSlots() { + return equipment; +} void Mob::dropEquipment(bool byPlayer, int playerBonusLevel) { for (int slot = 0; slot < (int)getEquipmentSlots().size(); slot++) { @@ -854,7 +853,7 @@ void Mob::restoreLeashFromSave() { if (leashInfoTag->contains(L"UUID")) { std::wstring leashUuid = leashInfoTag->getString(L"UUID"); AABB grown = bb.grow(10, 10, 10); - std::vector >* livingEnts = + std::vector>* livingEnts = level->getEntitiesOfClass(typeid(LivingEntity), &grown); for (auto it = livingEnts->begin(); it != livingEnts->end(); ++it) { std::shared_ptr le = diff --git a/targets/minecraft/world/entity/Painting.cpp b/targets/minecraft/world/entity/Painting.cpp index a9a9c3244..5e16942df 100644 --- a/targets/minecraft/world/entity/Painting.cpp +++ b/targets/minecraft/world/entity/Painting.cpp @@ -146,6 +146,5 @@ void Painting::dropItem(std::shared_ptr causedBy) { } } - spawnAtLocation( - std::make_shared(Item::painting), 0.0f); + spawnAtLocation(std::make_shared(Item::painting), 0.0f); } \ No newline at end of file diff --git a/targets/minecraft/world/entity/ai/village/VillageSiege.cpp b/targets/minecraft/world/entity/ai/village/VillageSiege.cpp index 371f90ece..1bfcfadee 100644 --- a/targets/minecraft/world/entity/ai/village/VillageSiege.cpp +++ b/targets/minecraft/world/entity/ai/village/VillageSiege.cpp @@ -94,13 +94,13 @@ bool VillageSiege::tryToSetupSiege() { bool overlaps = false; for (int i = 0; i < 10; ++i) { - spawnX = center->x + - (int)(cosf(level->random->nextFloat() * std::numbers::pi * 2.f) * - radius * 0.9); + spawnX = center->x + (int)(cosf(level->random->nextFloat() * + std::numbers::pi * 2.f) * + radius * 0.9); spawnY = center->y; - spawnZ = center->z + - (int)(sinf(level->random->nextFloat() * std::numbers::pi * 2.f) * - radius * 0.9); + spawnZ = center->z + (int)(sinf(level->random->nextFloat() * + std::numbers::pi * 2.f) * + radius * 0.9); overlaps = false; std::vector >* villages = level->villages->getVillages(); diff --git a/targets/minecraft/world/entity/ai/village/Villages.cpp b/targets/minecraft/world/entity/ai/village/Villages.cpp index a2a96a3a6..b1144e9c6 100644 --- a/targets/minecraft/world/entity/ai/village/Villages.cpp +++ b/targets/minecraft/world/entity/ai/village/Villages.cpp @@ -121,8 +121,7 @@ void Villages::cluster() { if (found) continue; // create new Village - std::shared_ptr village = - std::make_shared(level); + std::shared_ptr village = std::make_shared(level); village->addDoorInfo(di); villages.push_back(village); setDirty(); @@ -206,8 +205,7 @@ void Villages::load(CompoundTag* tag) { (ListTag*)tag->getList(L"Villages"); for (int i = 0; i < villageTags->size(); i++) { CompoundTag* compoundTag = villageTags->get(i); - std::shared_ptr village = - std::make_shared(); + std::shared_ptr village = std::make_shared(); village->readAdditionalSaveData(compoundTag); villages.push_back(village); } diff --git a/targets/minecraft/world/entity/animal/EntityHorse.cpp b/targets/minecraft/world/entity/animal/EntityHorse.cpp index bec7af085..d9f1c5b20 100644 --- a/targets/minecraft/world/entity/animal/EntityHorse.cpp +++ b/targets/minecraft/world/entity/animal/EntityHorse.cpp @@ -144,7 +144,6 @@ EntityHorse::EntityHorse(Level* level) : Animal(level) { createInventory(); } - void EntityHorse::defineSynchedData() { Animal::defineSynchedData(); entityData->define(DATA_ID_HORSE_FLAGS, 0); @@ -1285,9 +1284,8 @@ void EntityHorse::readAdditionalSaveData(CompoundTag* tag) { inventory->setItem(INV_SLOT_SADDLE, saddleItem); } } else if (tag->getBoolean(L"Saddle")) { - inventory->setItem( - INV_SLOT_SADDLE, - std::make_shared(Item::saddle)); + inventory->setItem(INV_SLOT_SADDLE, + std::make_shared(Item::saddle)); } updateEquipment(); } @@ -1313,8 +1311,7 @@ std::shared_ptr EntityHorse::getBreedOffspring( std::shared_ptr partner) { std::shared_ptr horsePartner = std::dynamic_pointer_cast(partner); - std::shared_ptr baby = - std::make_shared(level); + std::shared_ptr baby = std::make_shared(level); int type = getType(); int partnerType = horsePartner->getType(); diff --git a/targets/minecraft/world/entity/animal/Ocelot.cpp b/targets/minecraft/world/entity/animal/Ocelot.cpp index 11c5d163f..5d9aed46c 100644 --- a/targets/minecraft/world/entity/animal/Ocelot.cpp +++ b/targets/minecraft/world/entity/animal/Ocelot.cpp @@ -229,8 +229,7 @@ std::shared_ptr Ocelot::getBreedOffspring( std::shared_ptr target) { // 4J - added limit to number of animals that can be bred if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) { - std::shared_ptr offspring = - std::make_shared(level); + std::shared_ptr offspring = std::make_shared(level); if (isTame()) { offspring->setOwnerUUID(getOwnerUUID()); offspring->setTame(true); @@ -314,8 +313,7 @@ MobGroupData* Ocelot::finalizeMobSpawn( #endif if (level->random->nextInt(7) == 0) { for (int kitten = 0; kitten < 2; kitten++) { - std::shared_ptr ocelot = - std::make_shared(level); + std::shared_ptr ocelot = std::make_shared(level); ocelot->moveTo(x, y, z, yRot, 0); ocelot->setAge(-20 * 60 * 20); level->addEntity(ocelot); diff --git a/targets/minecraft/world/entity/animal/Pig.cpp b/targets/minecraft/world/entity/animal/Pig.cpp index 64399da8d..f6ade0a90 100644 --- a/targets/minecraft/world/entity/animal/Pig.cpp +++ b/targets/minecraft/world/entity/animal/Pig.cpp @@ -140,8 +140,7 @@ void Pig::setSaddle(bool value) { void Pig::thunderHit(const LightningBolt* lightningBolt) { if (level->isClientSide) return; - std::shared_ptr pz = - std::make_shared(level); + std::shared_ptr pz = std::make_shared(level); pz->moveTo(x, y, z, yRot, xRot); level->addEntity(pz); remove(); diff --git a/targets/minecraft/world/entity/animal/Sheep.cpp b/targets/minecraft/world/entity/animal/Sheep.cpp index c4b61b5b4..e55756180 100644 --- a/targets/minecraft/world/entity/animal/Sheep.cpp +++ b/targets/minecraft/world/entity/animal/Sheep.cpp @@ -152,7 +152,8 @@ float Sheep::getHeadEatAngleScale(float a) { if (eatAnimationTick > 4 && eatAnimationTick <= (EAT_ANIMATION_TICKS - 4)) { float scale = ((float)(eatAnimationTick - 4) - a) / (float)(EAT_ANIMATION_TICKS - 8); - return std::numbers::pi * .20f + std::numbers::pi * .07f * sinf(scale * 28.7f); + return std::numbers::pi * .20f + + std::numbers::pi * .07f * sinf(scale * 28.7f); } if (eatAnimationTick > 0) { return std::numbers::pi * .20f; diff --git a/targets/minecraft/world/entity/animal/Squid.cpp b/targets/minecraft/world/entity/animal/Squid.cpp index faf5920a0..61fc7d1f5 100644 --- a/targets/minecraft/world/entity/animal/Squid.cpp +++ b/targets/minecraft/world/entity/animal/Squid.cpp @@ -63,8 +63,8 @@ bool Squid::makeStepSound() { return false; } void Squid::dropDeathLoot(bool wasKilledByPlayer, int playerBonusLevel) { int count = random->nextInt(3 + playerBonusLevel) + 1; for (int i = 0; i < count; i++) { - spawnAtLocation(std::make_shared( - Item::dye_powder, 1, DyePowderItem::BLACK), + spawnAtLocation(std::make_shared(Item::dye_powder, 1, + DyePowderItem::BLACK), 0.0f); } } @@ -95,7 +95,8 @@ void Squid::aiStep() { if (tentacleMovement < std::numbers::pi) { float tentacleScale = tentacleMovement / std::numbers::pi; tentacleAngle = - sinf(tentacleScale * tentacleScale * std::numbers::pi) * std::numbers::pi * 0.25f; + sinf(tentacleScale * tentacleScale * std::numbers::pi) * + std::numbers::pi * 0.25f; if (tentacleScale > .75) { speed = 1.0f; @@ -117,14 +118,18 @@ void Squid::aiStep() { double horizontalMovement = sqrt(xd * xd + zd * zd); - yBodyRot += ((-(float)atan2(xd, zd) * 180 / std::numbers::pi) - yBodyRot) * 0.1f; + yBodyRot += + ((-(float)atan2(xd, zd) * 180 / std::numbers::pi) - yBodyRot) * + 0.1f; yRot = yBodyRot; zBodyRot = zBodyRot + (float)std::numbers::pi * rotateSpeed * 1.5f; xBodyRot += - ((-(float)atan2(horizontalMovement, yd) * 180 / std::numbers::pi) - xBodyRot) * + ((-(float)atan2(horizontalMovement, yd) * 180 / std::numbers::pi) - + xBodyRot) * 0.1f; } else { - tentacleAngle = Mth::abs(sinf(tentacleMovement)) * std::numbers::pi * 0.25f; + tentacleAngle = + Mth::abs(sinf(tentacleMovement)) * std::numbers::pi * 0.25f; if (!level->isClientSide) { // unable to move, apply gravity diff --git a/targets/minecraft/world/entity/animal/Wolf.cpp b/targets/minecraft/world/entity/animal/Wolf.cpp index 1d98e0a76..380b0fb64 100644 --- a/targets/minecraft/world/entity/animal/Wolf.cpp +++ b/targets/minecraft/world/entity/animal/Wolf.cpp @@ -238,8 +238,8 @@ float Wolf::getBodyRollAngle(float a, float offset) { } else if (progress > 1) { progress = 1; } - return sinf(progress * std::numbers::pi) * sinf(progress * std::numbers::pi * 11.0f) * 0.15f * - std::numbers::pi; + return sinf(progress * std::numbers::pi) * + sinf(progress * std::numbers::pi * 11.0f) * 0.15f * std::numbers::pi; } float Wolf::getHeadRollAngle(float a) { @@ -461,8 +461,7 @@ std::shared_ptr Wolf::getBreedOffspring( std::shared_ptr target) { // 4J - added limit to wolves that can be bred if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) { - std::shared_ptr pBabyWolf = - std::make_shared(level); + std::shared_ptr pBabyWolf = std::make_shared(level); if (!getOwnerUUID().empty()) { // set the baby wolf to be tame, and assign the owner diff --git a/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp b/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp index f1d6fa20f..b759498c9 100644 --- a/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp +++ b/targets/minecraft/world/entity/boss/enderdragon/EnderDragon.cpp @@ -168,7 +168,8 @@ void EnderDragon::defineSynchedData() { e_EnderdragonAction_HoldingPattern); } -void EnderDragon::getLatencyPos(std::vector& result, int step, float a) { +void EnderDragon::getLatencyPos(std::vector& result, int step, + float a) { if (getHealth() <= 0) { a = 0; } @@ -319,7 +320,7 @@ void EnderDragon::aiStep() { // d < 3; ++d) { Vec3 vN = Vec3{v.x, v.y, v.z}.normalize(); - vN.yRot(-std::numbers::pi / 4); + vN.yRot(-std::numbers::pi / 4); for (unsigned int i = 0; i < 8; ++i) { if (getSynchedAction() == e_EnderdragonAction_Landing) { @@ -484,7 +485,8 @@ void EnderDragon::aiStep() { Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z)) .normalize(); - Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0, -cos(yRot * std::numbers::pi / 180)) + Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0, + -cos(yRot * std::numbers::pi / 180)) .normalize(); float dot = (float)dir.dot(aim); @@ -498,7 +500,8 @@ void EnderDragon::aiStep() { // 2); double zdd = attackTarget->z - head->z; - double yRotT = (180) - atan2(xdd, zdd) * 180 / std::numbers::pi; + double yRotT = + (180) - atan2(xdd, zdd) * 180 / std::numbers::pi; double yRotD = Mth::wrapDegrees(yRotT - yRot); if (yRotD > 50) yRotD = 50; @@ -568,7 +571,8 @@ void EnderDragon::aiStep() { Vec3 aim = Vec3((xTarget - x), (yTarget - y), (zTarget - z)).normalize(); - Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), yd, -cos(yRot * std::numbers::pi / 180)) + Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), yd, + -cos(yRot * std::numbers::pi / 180)) .normalize(); float dot = (float)(dir.dot(aim) + 0.5f) / 1.5f; if (dot < 0) dot = 0; @@ -620,8 +624,9 @@ void EnderDragon::aiStep() { wing2->bbWidth = 4; // double latencyPosAcomponents[3],latencyPosBcomponents[3]; - // std::vector latencyPosA = std::vector(latencyPosAcomponents,3); - // std::vector latencyPosB = std::vector(latencyPosBcomponents,3); + // std::vector latencyPosA = + // std::vector(latencyPosAcomponents,3); std::vector + // latencyPosB = std::vector(latencyPosBcomponents,3); // getLatencyPos(latencyPosA, 5, 1); // getLatencyPos(latencyPosB, 10, 1); @@ -660,18 +665,21 @@ void EnderDragon::aiStep() { } double p1components[3]; - std::vector p1 = std::vector(p1components, p1components + 3); + std::vector p1 = + std::vector(p1components, p1components + 3); getLatencyPos(p1, 5, 1); { // double p0components[3]; - // std::vector p0 = std::vector(p0components, p0components + 3); - // getLatencyPos(p0, 0, 1); + // std::vector p0 = std::vector(p0components, + // p0components + 3); getLatencyPos(p0, 0, 1); double yRotDiff = getHeadYRotDiff(1); - float ss = sin((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f); - float cc = cos((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f); + float ss = + sin((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f); + float cc = + cos((yRot + yRotDiff) * std::numbers::pi / 180 - yRotA * 0.01f); head->tick(); neck->tick(); double yOffset = getHeadYOffset(1); // (p0[1] - p1[1]) * 1 @@ -715,10 +723,12 @@ void EnderDragon::aiStep() { if (i == 2) part = tail3; double p0components[3]; - std::vector p0 = std::vector(p0components, p0components + 3); + std::vector p0 = + std::vector(p0components, p0components + 3); getLatencyPos(p0, 12 + i * 2, 1); - float rot = yRot * std::numbers::pi / 180 + rotWrap(p0[0] - p1[0]) * std::numbers::pi / 180 * (1); + float rot = yRot * std::numbers::pi / 180 + + rotWrap(p0[0] - p1[0]) * std::numbers::pi / 180 * (1); float ss = sin(rot); float cc = cos(rot); @@ -742,7 +752,8 @@ void EnderDragon::aiStep() { Vec3 aim = Vec3((attackTarget->x - x), 0, (attackTarget->z - z)) .normalize(); - Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0, -cos(yRot * std::numbers::pi / 180)) + Vec3 dir = Vec3(sin(yRot * std::numbers::pi / 180), 0, + -cos(yRot * std::numbers::pi / 180)) .normalize(); float dot = (float)dir.dot(aim); @@ -1532,18 +1543,24 @@ int EnderDragon::findClosestNode() { int yAdjustment = 5; multiplier = i; if (i < 12) { - nodeX = 60 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 12) * multiplier)); - nodeZ = 60 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 12) * multiplier)); + nodeX = 60 * cosf(2 * (-std::numbers::pi + + (std::numbers::pi / 12) * multiplier)); + nodeZ = 60 * sinf(2 * (-std::numbers::pi + + (std::numbers::pi / 12) * multiplier)); } else if (i < 20) { multiplier -= 12; - nodeX = 40 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 8) * multiplier)); - nodeZ = 40 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 8) * multiplier)); + nodeX = 40 * cosf(2 * (-std::numbers::pi + + (std::numbers::pi / 8) * multiplier)); + nodeZ = 40 * sinf(2 * (-std::numbers::pi + + (std::numbers::pi / 8) * multiplier)); yAdjustment += 10; // Make the target well above the top of the towers } else { multiplier -= 20; - nodeX = 20 * cosf(2 * (-std::numbers::pi + (std::numbers::pi / 4) * multiplier)); - nodeZ = 20 * sinf(2 * (-std::numbers::pi + (std::numbers::pi / 4) * multiplier)); + nodeX = 20 * cosf(2 * (-std::numbers::pi + + (std::numbers::pi / 4) * multiplier)); + nodeZ = 20 * sinf(2 * (-std::numbers::pi + + (std::numbers::pi / 4) * multiplier)); } // Fix for #77202 - TU9: Content: Gameplay: The Ender Dragon // sometimes flies through terrain Add minimum height @@ -1762,8 +1779,10 @@ float EnderDragon::getTilt(float a) { // else { double latencyPosAcomponents[3], latencyPosBcomponents[3]; - std::vector latencyPosA = std::vector(latencyPosAcomponents, latencyPosAcomponents + 3); - std::vector latencyPosB = std::vector(latencyPosBcomponents, latencyPosBcomponents + 3); + std::vector latencyPosA = std::vector( + latencyPosAcomponents, latencyPosAcomponents + 3); + std::vector latencyPosB = std::vector( + latencyPosBcomponents, latencyPosBcomponents + 3); getLatencyPos(latencyPosA, 5, a); getLatencyPos(latencyPosB, 10, a); @@ -1782,11 +1801,13 @@ double EnderDragon::getHeadYOffset(float a) { headYOffset = -1.0; } else { double p1components[3]; - std::vector p1 = std::vector(p1components, p1components + 3); + std::vector p1 = + std::vector(p1components, p1components + 3); getLatencyPos(p1, 5, 1); double p0components[3]; - std::vector p0 = std::vector(p0components, p0components + 3); + std::vector p0 = + std::vector(p0components, p0components + 3); getLatencyPos(p0, 0, 1); headYOffset = (p0[1] - p1[1]) * 1; @@ -1806,7 +1827,8 @@ double EnderDragon::getHeadYRotDiff(float a) { return result; } -double EnderDragon::getHeadPartYOffset(int partIndex, std::vector& bodyPos, +double EnderDragon::getHeadPartYOffset(int partIndex, + std::vector& bodyPos, std::vector& partPos) { double result = 0.0; if (getSynchedAction() == e_EnderdragonAction_Landing || @@ -1834,7 +1856,8 @@ double EnderDragon::getHeadPartYOffset(int partIndex, std::vector& bodyP return result; } -double EnderDragon::getHeadPartYRotDiff(int partIndex, std::vector& bodyPos, +double EnderDragon::getHeadPartYRotDiff(int partIndex, + std::vector& bodyPos, std::vector& partPos) { double result = 0.0; // if( getSynchedAction() == e_EnderdragonAction_Sitting_Flaming || diff --git a/targets/minecraft/world/entity/boss/wither/WitherBoss.cpp b/targets/minecraft/world/entity/boss/wither/WitherBoss.cpp index 9c452fea7..cca117cdf 100644 --- a/targets/minecraft/world/entity/boss/wither/WitherBoss.cpp +++ b/targets/minecraft/world/entity/boss/wither/WitherBoss.cpp @@ -347,7 +347,8 @@ double WitherBoss::getHeadX(int index) { if (index <= 0) { return x; } - float headAngle = (yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi; + float headAngle = + (yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi; float cos = cosf(headAngle); return x + cos * 1.3; } @@ -364,7 +365,8 @@ double WitherBoss::getHeadZ(int index) { if (index <= 0) { return z; } - float headAngle = (yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi; + float headAngle = + (yBodyRot + 180 * (index - 1)) / 180.0f * std::numbers::pi; float sin = sinf(headAngle); return z + sin * 1.3; } @@ -400,10 +402,9 @@ void WitherBoss::performRangedAttack(int head, double tx, double ty, double tz, double yd = ty - hy; double zd = tz - hz; - std::shared_ptr ie = - std::make_shared( - level, std::dynamic_pointer_cast(shared_from_this()), - xd, yd, zd); + std::shared_ptr ie = std::make_shared( + level, std::dynamic_pointer_cast(shared_from_this()), xd, + yd, zd); if (dangerous) ie->setDangerous(true); ie->y = hy; ie->x = hx; diff --git a/targets/minecraft/world/entity/item/FallingTile.cpp b/targets/minecraft/world/entity/item/FallingTile.cpp index 136c921fc..fa48e558d 100644 --- a/targets/minecraft/world/entity/item/FallingTile.cpp +++ b/targets/minecraft/world/entity/item/FallingTile.cpp @@ -134,8 +134,8 @@ void FallingTile::tick() { CompoundTag* swap = new CompoundTag(); tileEntity->save(swap); std::vector allTags = tileData->getAllTags(); - for (auto it = allTags.begin(); - it != allTags.end(); ++it) { + for (auto it = allTags.begin(); it != allTags.end(); + ++it) { Tag* tag = *it; if (tag->getName().compare(L"x") == 0 || tag->getName().compare(L"y") == 0 || diff --git a/targets/minecraft/world/entity/item/Minecart.cpp b/targets/minecraft/world/entity/item/Minecart.cpp index de98b8fb3..746b611a9 100644 --- a/targets/minecraft/world/entity/item/Minecart.cpp +++ b/targets/minecraft/world/entity/item/Minecart.cpp @@ -757,7 +757,8 @@ void Minecart::push(std::shared_ptr e) { Vec3 dir(xo, 0, zo); dir = dir.normalize(); - Vec3 facing(cos(yRot * std::numbers::pi / 180), 0, sin(yRot * std::numbers::pi / 180)); + Vec3 facing(cos(yRot * std::numbers::pi / 180), 0, + sin(yRot * std::numbers::pi / 180)); facing = facing.normalize(); double dot = abs(dir.dot(facing)); diff --git a/targets/minecraft/world/entity/item/MinecartContainer.cpp b/targets/minecraft/world/entity/item/MinecartContainer.cpp index 1f4ea2eca..2e07372db 100644 --- a/targets/minecraft/world/entity/item/MinecartContainer.cpp +++ b/targets/minecraft/world/entity/item/MinecartContainer.cpp @@ -42,8 +42,8 @@ void MinecartContainer::destroy(DamageSource* source) { std::shared_ptr itemEntity = std::make_shared( level, x + xo, y + yo, z + zo, - std::make_shared( - item->id, count, item->getAuxValue())); + std::make_shared(item->id, count, + item->getAuxValue())); float pow = 0.05f; itemEntity->xd = (float)random->nextGaussian() * pow; itemEntity->yd = (float)random->nextGaussian() * pow + 0.2f; diff --git a/targets/minecraft/world/entity/item/MinecartFurnace.cpp b/targets/minecraft/world/entity/item/MinecartFurnace.cpp index a72d792b9..65ffbc2f6 100644 --- a/targets/minecraft/world/entity/item/MinecartFurnace.cpp +++ b/targets/minecraft/world/entity/item/MinecartFurnace.cpp @@ -66,9 +66,7 @@ void MinecartFurnace::destroy(DamageSource* source) { Minecart::destroy(source); if (!source->isExplosion()) { - spawnAtLocation( - std::make_shared(Tile::furnace, 1), - 0); + spawnAtLocation(std::make_shared(Tile::furnace, 1), 0); } } diff --git a/targets/minecraft/world/entity/item/MinecartTNT.cpp b/targets/minecraft/world/entity/item/MinecartTNT.cpp index 2643676ad..cc360563e 100644 --- a/targets/minecraft/world/entity/item/MinecartTNT.cpp +++ b/targets/minecraft/world/entity/item/MinecartTNT.cpp @@ -57,8 +57,7 @@ void MinecartTNT::destroy(DamageSource* source) { double speedSqr = xd * xd + zd * zd; if (!source->isExplosion()) { - spawnAtLocation( - std::make_shared(Tile::tnt, 1), 0); + spawnAtLocation(std::make_shared(Tile::tnt, 1), 0); } if (source->isFire() || source->isExplosion() || speedSqr >= 0.01f) { diff --git a/targets/minecraft/world/entity/monster/EnderMan.cpp b/targets/minecraft/world/entity/monster/EnderMan.cpp index 579d0fae8..d6b92ecc0 100644 --- a/targets/minecraft/world/entity/monster/EnderMan.cpp +++ b/targets/minecraft/world/entity/monster/EnderMan.cpp @@ -39,7 +39,7 @@ AttributeModifier* EnderMan::SPEED_MODIFIER_ATTACKING = bool EnderMan::MAY_TAKE[256]; void EnderMan::staticCtor() { - memset(MAY_TAKE, 0, sizeof(bool) * 256); + memset(MAY_TAKE, 0, sizeof(bool) * 256); MAY_TAKE[Tile::grass_Id] = true; MAY_TAKE[Tile::dirt_Id] = true; MAY_TAKE[Tile::sand_Id] = true; diff --git a/targets/minecraft/world/entity/monster/Ghast.cpp b/targets/minecraft/world/entity/monster/Ghast.cpp index fb355f32f..bfbb738b9 100644 --- a/targets/minecraft/world/entity/monster/Ghast.cpp +++ b/targets/minecraft/world/entity/monster/Ghast.cpp @@ -164,7 +164,8 @@ void Ghast::serverAiStep() { if (charge > 0) charge--; } } else { - yBodyRot = yRot = -(float)atan2(this->xd, this->zd) * 180 / std::numbers::pi; + yBodyRot = yRot = + -(float)atan2(this->xd, this->zd) * 180 / std::numbers::pi; if (charge > 0) charge--; } diff --git a/targets/minecraft/world/entity/monster/Monster.cpp b/targets/minecraft/world/entity/monster/Monster.cpp index 67db53f89..26ee4fa97 100644 --- a/targets/minecraft/world/entity/monster/Monster.cpp +++ b/targets/minecraft/world/entity/monster/Monster.cpp @@ -100,7 +100,8 @@ bool Monster::doHurtTarget(std::shared_ptr target) { if (wasHurt) { if (knockback > 0) { - target->push(-sinf(yRot * std::numbers::pi / 180) * knockback * .5f, 0.1, + target->push(-sinf(yRot * std::numbers::pi / 180) * knockback * .5f, + 0.1, cosf(yRot * std::numbers::pi / 180) * knockback * .5f); xd *= 0.6; zd *= 0.6; diff --git a/targets/minecraft/world/entity/monster/SharedMonsterAttributes.h b/targets/minecraft/world/entity/monster/SharedMonsterAttributes.h index ed5415ac3..c427355bd 100644 --- a/targets/minecraft/world/entity/monster/SharedMonsterAttributes.h +++ b/targets/minecraft/world/entity/monster/SharedMonsterAttributes.h @@ -5,7 +5,8 @@ class AttributeInstance; class AttributeModifier; class BaseAttributeMap; class CompoundTag; -template class ListTag; +template +class ListTag; class SharedMonsterAttributes { public: diff --git a/targets/minecraft/world/entity/monster/Skeleton.cpp b/targets/minecraft/world/entity/monster/Skeleton.cpp index 2ea4ced9f..04e47a85c 100644 --- a/targets/minecraft/world/entity/monster/Skeleton.cpp +++ b/targets/minecraft/world/entity/monster/Skeleton.cpp @@ -214,8 +214,7 @@ void Skeleton::dropRareDeathLoot(int rareLootLevel) { void Skeleton::populateDefaultEquipmentSlots() { Monster::populateDefaultEquipmentSlots(); - setEquippedSlot(SLOT_WEAPON, - std::make_shared(Item::bow)); + setEquippedSlot(SLOT_WEAPON, std::make_shared(Item::bow)); } MobGroupData* Skeleton::finalizeMobSpawn( diff --git a/targets/minecraft/world/entity/monster/Spider.cpp b/targets/minecraft/world/entity/monster/Spider.cpp index 23ae49e10..afbae0045 100644 --- a/targets/minecraft/world/entity/monster/Spider.cpp +++ b/targets/minecraft/world/entity/monster/Spider.cpp @@ -159,8 +159,7 @@ MobGroupData* Spider::finalizeMobSpawn( if (level->random->nextInt(100) == 0) #endif { - std::shared_ptr skeleton = - std::make_shared(level); + std::shared_ptr skeleton = std::make_shared(level); skeleton->moveTo(x, y, z, yRot, 0); skeleton->finalizeMobSpawn(nullptr); level->addEntity(skeleton); diff --git a/targets/minecraft/world/entity/monster/Witch.cpp b/targets/minecraft/world/entity/monster/Witch.cpp index 320e65cef..00347d6e0 100644 --- a/targets/minecraft/world/entity/monster/Witch.cpp +++ b/targets/minecraft/world/entity/monster/Witch.cpp @@ -211,10 +211,9 @@ void Witch::performRangedAttack(std::shared_ptr target, float power) { if (isUsingItem()) return; - std::shared_ptr potion = - std::make_shared( - level, std::dynamic_pointer_cast(shared_from_this()), - PotionBrewing::POTION_ID_SPLASH_DAMAGE); + std::shared_ptr potion = std::make_shared( + level, std::dynamic_pointer_cast(shared_from_this()), + PotionBrewing::POTION_ID_SPLASH_DAMAGE); potion->xRot -= -20; double xd = (target->x + target->xd) - x; double yd = (target->y + target->getHeadHeight() - 1.1f) - y; diff --git a/targets/minecraft/world/entity/monster/Zombie.cpp b/targets/minecraft/world/entity/monster/Zombie.cpp index 0cae9c650..2eaf8841d 100644 --- a/targets/minecraft/world/entity/monster/Zombie.cpp +++ b/targets/minecraft/world/entity/monster/Zombie.cpp @@ -193,13 +193,13 @@ bool Zombie::hurt(DamageSource* source, float dmg) { for (int i = 0; i < REINFORCEMENT_ATTEMPTS; i++) { int xt = x + random->nextInt(REINFORCEMENT_RANGE_MIN, - REINFORCEMENT_RANGE_MAX) * + REINFORCEMENT_RANGE_MAX) * random->nextInt(-1, 1); int yt = y + random->nextInt(REINFORCEMENT_RANGE_MIN, - REINFORCEMENT_RANGE_MAX) * + REINFORCEMENT_RANGE_MAX) * random->nextInt(-1, 1); int zt = z + random->nextInt(REINFORCEMENT_RANGE_MIN, - REINFORCEMENT_RANGE_MAX) * + REINFORCEMENT_RANGE_MAX) * random->nextInt(-1, 1); if (level->isTopSolidBlocking(xt, yt - 1, zt) && @@ -334,8 +334,7 @@ void Zombie::killed(std::shared_ptr mob) { if (level->difficulty == Difficulty::NORMAL && random->nextBoolean()) return; - std::shared_ptr zombie = - std::make_shared(level); + std::shared_ptr zombie = std::make_shared(level); zombie->copyPosition(mob); level->removeEntity(mob); zombie->finalizeMobSpawn(nullptr); @@ -473,8 +472,7 @@ bool Zombie::isConverting() { } void Zombie::finishConversion() { - std::shared_ptr villager = - std::make_shared(level); + std::shared_ptr villager = std::make_shared(level); villager->copyPosition(shared_from_this()); villager->finalizeMobSpawn(nullptr); villager->setRewardPlayersInVillage(); diff --git a/targets/minecraft/world/entity/npc/Villager.cpp b/targets/minecraft/world/entity/npc/Villager.cpp index a07ac9a1f..9c580aa8e 100644 --- a/targets/minecraft/world/entity/npc/Villager.cpp +++ b/targets/minecraft/world/entity/npc/Villager.cpp @@ -372,8 +372,8 @@ void Villager::addOffers(int addCount) { new ItemInstance(Tile::gravel, 10)), std::shared_ptr( new ItemInstance(Item::emerald)), - std::make_shared( - Item::flint_Id, 4 + random->nextInt(2), 0))); + std::make_shared(Item::flint_Id, + 4 + random->nextInt(2), 0))); } break; case PROFESSION_BUTCHER: @@ -474,7 +474,7 @@ void Villager::addOffers(int addCount) { Enchantment::validEnchantments[random->nextInt( Enchantment::validEnchantments.size())]; int level = random->nextInt(enchantment->getMinLevel(), - enchantment->getMaxLevel()); + enchantment->getMaxLevel()); std::shared_ptr book = Item::enchantedBook->createForEnchantment( new EnchantmentInstance(enchantment, level)); @@ -668,8 +668,7 @@ void Villager::addItemForPurchase(MerchantRecipeList* list, int itemId, } else { rubyItem = std::shared_ptr( new ItemInstance(Item::emerald_Id, purchaseCost, 0)); - resultItem = - std::make_shared(itemId, 1, 0); + resultItem = std::make_shared(itemId, 1, 0); } list->push_back(new MerchantRecipe(rubyItem, resultItem)); } @@ -729,8 +728,7 @@ std::shared_ptr Villager::getBreedOffspring( std::shared_ptr target) { // 4J - added limit to villagers that can be bred if (level->canCreateMore(GetType(), Level::eSpawnType_Breed)) { - std::shared_ptr villager = - std::make_shared(level); + std::shared_ptr villager = std::make_shared(level); villager->finalizeMobSpawn(nullptr); return villager; } else { diff --git a/targets/minecraft/world/entity/player/Inventory.cpp b/targets/minecraft/world/entity/player/Inventory.cpp index d7bfa9828..61111cff9 100644 --- a/targets/minecraft/world/entity/player/Inventory.cpp +++ b/targets/minecraft/world/entity/player/Inventory.cpp @@ -28,8 +28,7 @@ Inventory::Inventory(Player* player) { this->player = player; } -Inventory::~Inventory() { -} +Inventory::~Inventory() {} std::shared_ptr Inventory::getSelected() { // sanity checking to prevent exploits @@ -341,7 +340,8 @@ bool Inventory::add(std::shared_ptr item) { std::shared_ptr Inventory::removeItem(unsigned int slot, int count) { - std::vector>& pile = (slot >= items.size()) ? armor : items; + std::vector>& pile = + (slot >= items.size()) ? armor : items; if (slot >= items.size()) { slot -= items.size(); } @@ -361,7 +361,8 @@ std::shared_ptr Inventory::removeItem(unsigned int slot, } std::shared_ptr Inventory::removeItemNoUpdate(int slot) { - std::vector>& pile = (slot >= (int)items.size()) ? armor : items; + std::vector>& pile = + (slot >= (int)items.size()) ? armor : items; if (slot >= (int)items.size()) { slot -= items.size(); } @@ -564,8 +565,7 @@ bool Inventory::isSame(std::shared_ptr a, } std::shared_ptr Inventory::copy() { - std::shared_ptr copy = - std::make_shared(nullptr); + std::shared_ptr copy = std::make_shared(nullptr); for (unsigned int i = 0; i < items.size(); i++) { copy->items[i] = items[i] != nullptr ? items[i]->copy() : nullptr; } diff --git a/targets/minecraft/world/entity/player/Player.cpp b/targets/minecraft/world/entity/player/Player.cpp index cc56e4ed6..11abf3038 100644 --- a/targets/minecraft/world/entity/player/Player.cpp +++ b/targets/minecraft/world/entity/player/Player.cpp @@ -899,7 +899,7 @@ void Player::aiStep() { pickupArea = bb.grow(1, .5, 1); } - std::vector >* entities = + std::vector>* entities = level->getEntities(shared_from_this(), &pickupArea); if (entities != nullptr) { auto itEnd = entities->end(); @@ -934,8 +934,7 @@ void Player::die(DamageSource* source) { // 4J - TODO need to use a xuid if (app.isXuidNotch(m_xuid)) { - drop(std::make_shared(Item::apple, 1), - true); + drop(std::make_shared(Item::apple, 1), true); } if (!level->getGameRules()->getBoolean(GameRules::RULE_KEEPINVENTORY)) { inventory->dropAll(); @@ -1012,8 +1011,10 @@ std::shared_ptr Player::drop(std::shared_ptr item, } else { pow = 0.3f; - thrownItem->xd = -sin(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi) * pow; - thrownItem->zd = cos(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi) * pow; + thrownItem->xd = -sin(yRot / 180 * std::numbers::pi) * + cos(xRot / 180 * std::numbers::pi) * pow; + thrownItem->zd = cos(yRot / 180 * std::numbers::pi) * + cos(xRot / 180 * std::numbers::pi) * pow; thrownItem->yd = -sin(xRot / 180 * std::numbers::pi) * pow + 0.1f; pow = 0.02f; @@ -1396,8 +1397,9 @@ void Player::attack(std::shared_ptr entity) { delete damageSource; if (wasHurt) { if (knockback > 0) { - entity->push(-sinf(yRot * std::numbers::pi / 180) * knockback * .5f, 0.1, - cosf(yRot * std::numbers::pi / 180) * knockback * .5f); + entity->push( + -sinf(yRot * std::numbers::pi / 180) * knockback * .5f, 0.1, + cosf(yRot * std::numbers::pi / 180) * knockback * .5f); xd *= 0.6; zd *= 0.6; setSprinting(false); @@ -1528,7 +1530,7 @@ Player::BedSleepingResult Player::startSleepInBed(int x, int y, int z, double vRange = 5; AABB monster_bb = AABB(x, y, z, x, y, z).grow(hRange, vRange, hRange); - std::vector >* monsters = + std::vector>* monsters = level->getEntitiesOfClass(typeid(Monster), &monster_bb); if (!monsters->empty()) { delete monsters; @@ -2241,7 +2243,9 @@ bool Player::isInvisibleTo(std::shared_ptr player) { return isInvisible(); } -std::vector> Player::getEquipmentSlots() { return inventory->armor; } +std::vector> Player::getEquipmentSlots() { + return inventory->armor; +} bool Player::isCapeHidden() { return getPlayerFlag(FLAG_HIDE_CAPE); } diff --git a/targets/minecraft/world/entity/projectile/Arrow.cpp b/targets/minecraft/world/entity/projectile/Arrow.cpp index be1d13417..64a8231e5 100644 --- a/targets/minecraft/world/entity/projectile/Arrow.cpp +++ b/targets/minecraft/world/entity/projectile/Arrow.cpp @@ -123,8 +123,10 @@ Arrow::Arrow(Level* level, std::shared_ptr mob, float power) setPos(x, y, z); heightOffset = 0; - xd = -sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); - zd = cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi); + xd = -sinf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi); + zd = cosf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi); yd = -sinf(xRot / 180 * std::numbers::pi); shoot(xd, yd, zd, power * 1.5f, 1); diff --git a/targets/minecraft/world/entity/projectile/FishingHook.cpp b/targets/minecraft/world/entity/projectile/FishingHook.cpp index 160095eef..1f2bffd37 100644 --- a/targets/minecraft/world/entity/projectile/FishingHook.cpp +++ b/targets/minecraft/world/entity/projectile/FishingHook.cpp @@ -90,8 +90,12 @@ FishingHook::FishingHook(Level* level, std::shared_ptr mob) heightOffset = 0; float speed = 0.4f; - xd = (-sinf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi)) * speed; - zd = (cosf(yRot / 180 * std::numbers::pi) * cosf(xRot / 180 * std::numbers::pi)) * speed; + xd = (-sinf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi)) * + speed; + zd = (cosf(yRot / 180 * std::numbers::pi) * + cosf(xRot / 180 * std::numbers::pi)) * + speed; yd = (-sinf(xRot / 180 * std::numbers::pi)) * speed; shoot(xd, yd, zd, 1.5f, 1); @@ -408,10 +412,9 @@ int FishingHook::retrieve() { ie->Entity::yd = ya * speed + sqrt(dist) * 0.08; ie->Entity::zd = za * speed; level->addEntity(ie); - owner->level->addEntity( - std::make_shared( - owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f, - random->nextInt(6) + 1)); // 4J Stu brought forward from 1.4 + owner->level->addEntity(std::make_shared( + owner->level, owner->x, owner->y + 0.5f, owner->z + 0.5f, + random->nextInt(6) + 1)); // 4J Stu brought forward from 1.4 dmg = 1; } if (inGround) dmg = 2; diff --git a/targets/minecraft/world/entity/projectile/Throwable.cpp b/targets/minecraft/world/entity/projectile/Throwable.cpp index 4b2fa1304..9c3e747ac 100644 --- a/targets/minecraft/world/entity/projectile/Throwable.cpp +++ b/targets/minecraft/world/entity/projectile/Throwable.cpp @@ -58,9 +58,14 @@ Throwable::Throwable(Level* level, std::shared_ptr mob) heightOffset = 0; float speed = 0.4f; - xd = (-sin(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi)) * speed; - zd = (cos(yRot / 180 * std::numbers::pi) * cos(xRot / 180 * std::numbers::pi)) * speed; - yd = (-sin((xRot + getThrowUpAngleOffset()) / 180 * std::numbers::pi)) * speed; + xd = (-sin(yRot / 180 * std::numbers::pi) * + cos(xRot / 180 * std::numbers::pi)) * + speed; + zd = (cos(yRot / 180 * std::numbers::pi) * + cos(xRot / 180 * std::numbers::pi)) * + speed; + yd = (-sin((xRot + getThrowUpAngleOffset()) / 180 * std::numbers::pi)) * + speed; shoot(xd, yd, zd, getThrowPower(), 1); } diff --git a/targets/minecraft/world/entity/projectile/ThrownPotion.cpp b/targets/minecraft/world/entity/projectile/ThrownPotion.cpp index 93cb1c4b4..2dffe20fc 100644 --- a/targets/minecraft/world/entity/projectile/ThrownPotion.cpp +++ b/targets/minecraft/world/entity/projectile/ThrownPotion.cpp @@ -77,15 +77,13 @@ float ThrownPotion::getThrowUpAngleOffset() { return -20; } void ThrownPotion::setPotionValue(int potionValue) { if (potionItem == nullptr) - potionItem = - std::make_shared(Item::potion, 1, 0); + potionItem = std::make_shared(Item::potion, 1, 0); potionItem->setAuxValue(potionValue); } int ThrownPotion::getPotionValue() { if (potionItem == nullptr) - potionItem = - std::make_shared(Item::potion, 1, 0); + potionItem = std::make_shared(Item::potion, 1, 0); return potionItem->getAuxValue(); } diff --git a/targets/minecraft/world/inventory/AbstractContainerMenu.cpp b/targets/minecraft/world/inventory/AbstractContainerMenu.cpp index cfe9e5186..426a15c5e 100644 --- a/targets/minecraft/world/inventory/AbstractContainerMenu.cpp +++ b/targets/minecraft/world/inventory/AbstractContainerMenu.cpp @@ -41,7 +41,7 @@ Slot* AbstractContainerMenu::addSlot(Slot* slot) { void AbstractContainerMenu::addSlotListener(ContainerListener* listener) { containerListeners.push_back(listener); - std::vector >* items = getItems(); + std::vector>* items = getItems(); listener->refreshContainer(this, items); delete items; broadcastChanges(); @@ -53,9 +53,9 @@ void AbstractContainerMenu::removeSlotListener(ContainerListener* listener) { if (it != containerListeners.end()) containerListeners.erase(it); } -std::vector >* AbstractContainerMenu::getItems() { - std::vector >* items = - new std::vector >(); +std::vector>* AbstractContainerMenu::getItems() { + std::vector>* items = + new std::vector>(); auto itEnd = slots.end(); for (auto it = slots.begin(); it != itEnd; it++) { items->push_back((*it)->getItem()); @@ -507,7 +507,8 @@ void AbstractContainerMenu::setItem(unsigned int slot, getSlot(slot)->set(item); } -void AbstractContainerMenu::setAll(std::vector>* items) { +void AbstractContainerMenu::setAll( + std::vector>* items) { for (unsigned int i = 0; i < items->size(); i++) { getSlot(i)->set((*items)[i]); } diff --git a/targets/minecraft/world/inventory/AbstractContainerMenu.h b/targets/minecraft/world/inventory/AbstractContainerMenu.h index 577724eda..d01729388 100644 --- a/targets/minecraft/world/inventory/AbstractContainerMenu.h +++ b/targets/minecraft/world/inventory/AbstractContainerMenu.h @@ -44,7 +44,7 @@ public: static const int CONTAINER_ID_INVENTORY = 0; static const int CONTAINER_ID_CREATIVE = -2; - std::vector > lastSlots; + std::vector> lastSlots; std::vector slots; int containerId; @@ -72,7 +72,7 @@ public: virtual ~AbstractContainerMenu(); virtual void addSlotListener(ContainerListener* listener); virtual void removeSlotListener(ContainerListener* listener); - virtual std::vector >* getItems(); + virtual std::vector>* getItems(); virtual void sendData(int id, int value); virtual void broadcastChanges(); virtual bool needsRendered(); diff --git a/targets/minecraft/world/inventory/CraftingMenu.cpp b/targets/minecraft/world/inventory/CraftingMenu.cpp index 552c205cc..fbfb64fd0 100644 --- a/targets/minecraft/world/inventory/CraftingMenu.cpp +++ b/targets/minecraft/world/inventory/CraftingMenu.cpp @@ -25,8 +25,7 @@ const int CraftingMenu::USE_ROW_SLOT_END = CraftingMenu::USE_ROW_SLOT_START + 9; CraftingMenu::CraftingMenu(std::shared_ptr inventory, Level* level, int xt, int yt, int zt) : AbstractContainerMenu() { - craftSlots = - std::make_shared(this, 3, 3); + craftSlots = std::make_shared(this, 3, 3); resultSlots = std::make_shared(); this->level = level; diff --git a/targets/minecraft/world/inventory/EnchantmentMenu.cpp b/targets/minecraft/world/inventory/EnchantmentMenu.cpp index 19fb92efd..6beb09a74 100644 --- a/targets/minecraft/world/inventory/EnchantmentMenu.cpp +++ b/targets/minecraft/world/inventory/EnchantmentMenu.cpp @@ -21,8 +21,7 @@ EnchantmentMenu::EnchantmentMenu(std::shared_ptr inventory, Level* level, int xt, int yt, int zt) { - enchantSlots = - std::make_shared(this); + enchantSlots = std::make_shared(this); for (int i = 0; i < 3; ++i) { costs[i] = 0; diff --git a/targets/minecraft/world/inventory/FireworksMenu.cpp b/targets/minecraft/world/inventory/FireworksMenu.cpp index 728b780ac..2c72ad24d 100644 --- a/targets/minecraft/world/inventory/FireworksMenu.cpp +++ b/targets/minecraft/world/inventory/FireworksMenu.cpp @@ -21,8 +21,7 @@ FireworksMenu::FireworksMenu(std::shared_ptr inventory, Level* level, m_canMakeCharge = false; m_canMakeFade = false; - craftSlots = - std::make_shared(this, 3, 3); + craftSlots = std::make_shared(this, 3, 3); resultSlots = std::make_shared(); this->level = level; diff --git a/targets/minecraft/world/inventory/InventoryMenu.cpp b/targets/minecraft/world/inventory/InventoryMenu.cpp index 573d39c1e..a069a225a 100644 --- a/targets/minecraft/world/inventory/InventoryMenu.cpp +++ b/targets/minecraft/world/inventory/InventoryMenu.cpp @@ -35,8 +35,7 @@ InventoryMenu::InventoryMenu(std::shared_ptr inventory, bool active, } void InventoryMenu::_init(std::shared_ptr inventory, bool active) { - craftSlots = - std::make_shared(this, 2, 2); + craftSlots = std::make_shared(this, 2, 2); resultSlots = std::make_shared(); this->active = active; diff --git a/targets/minecraft/world/inventory/MenuBackup.cpp b/targets/minecraft/world/inventory/MenuBackup.cpp index 374e44c5e..2bfe2600d 100644 --- a/targets/minecraft/world/inventory/MenuBackup.cpp +++ b/targets/minecraft/world/inventory/MenuBackup.cpp @@ -8,7 +8,9 @@ MenuBackup::MenuBackup(std::shared_ptr inventory, AbstractContainerMenu* menu) { - backups = new std::unordered_map>*>(); + backups = + new std::unordered_map>*>(); this->inventory = inventory; this->menu = menu; @@ -16,7 +18,8 @@ MenuBackup::MenuBackup(std::shared_ptr inventory, void MenuBackup::save(short changeUid) { std::vector>* backup = - new std::vector>((int)menu->slots.size() + 1); + new std::vector>((int)menu->slots.size() + + 1); (*backup)[0] = ItemInstance::clone(inventory->getCarried()); for (unsigned int i = 0; i < menu->slots.size(); i++) { (*backup)[i + 1] = ItemInstance::clone(menu->slots.at(i)->getItem()); diff --git a/targets/minecraft/world/inventory/MenuBackup.h b/targets/minecraft/world/inventory/MenuBackup.h index 73f10c1ac..5f64ee1fe 100644 --- a/targets/minecraft/world/inventory/MenuBackup.h +++ b/targets/minecraft/world/inventory/MenuBackup.h @@ -10,7 +10,8 @@ class ItemInstance; class MenuBackup { private: - std::unordered_map>*>* backups; + std::unordered_map>*>* + backups; std::shared_ptr inventory; AbstractContainerMenu* menu; diff --git a/targets/minecraft/world/inventory/MerchantContainer.cpp b/targets/minecraft/world/inventory/MerchantContainer.cpp index 79427a08e..846e6df8e 100644 --- a/targets/minecraft/world/inventory/MerchantContainer.cpp +++ b/targets/minecraft/world/inventory/MerchantContainer.cpp @@ -19,7 +19,6 @@ MerchantContainer::MerchantContainer(std::shared_ptr player, selectionHint = 0; } - unsigned int MerchantContainer::getContainerSize() { return items.size(); } std::shared_ptr MerchantContainer::getItem(unsigned int slot) { diff --git a/targets/minecraft/world/item/ColoredTileItem.cpp b/targets/minecraft/world/item/ColoredTileItem.cpp index 084b6d790..aeaef18ea 100644 --- a/targets/minecraft/world/item/ColoredTileItem.cpp +++ b/targets/minecraft/world/item/ColoredTileItem.cpp @@ -14,8 +14,7 @@ ColoredTileItem::ColoredTileItem(int id, bool stackedByData) : TileItem(id) { } } -ColoredTileItem::~ColoredTileItem() { -} +ColoredTileItem::~ColoredTileItem() {} int ColoredTileItem::getColor(std::shared_ptr item, int spriteLayer) { diff --git a/targets/minecraft/world/item/ColoredTileItem.h b/targets/minecraft/world/item/ColoredTileItem.h index e39a60b9c..ad4a8d4d1 100644 --- a/targets/minecraft/world/item/ColoredTileItem.h +++ b/targets/minecraft/world/item/ColoredTileItem.h @@ -24,7 +24,8 @@ public: virtual Icon* getIcon(int auxValue); virtual int getLevelDataForAuxValue(int auxValue); - ColoredTileItem* setDescriptionPostfixes(std::vector& descriptionPostfixes); + ColoredTileItem* setDescriptionPostfixes( + std::vector& descriptionPostfixes); virtual unsigned int getDescriptionId( std::shared_ptr instance); }; diff --git a/targets/minecraft/world/item/DiggerItem.h b/targets/minecraft/world/item/DiggerItem.h index 2c255355e..1ad9ba7f7 100644 --- a/targets/minecraft/world/item/DiggerItem.h +++ b/targets/minecraft/world/item/DiggerItem.h @@ -21,7 +21,8 @@ private: protected: const Tier* tier; - DiggerItem(int id, float attackDamage, const Tier* tier, std::vector* tiles); + DiggerItem(int id, float attackDamage, const Tier* tier, + std::vector* tiles); public: virtual float getDestroySpeed(std::shared_ptr itemInstance, diff --git a/targets/minecraft/world/item/EggItem.cpp b/targets/minecraft/world/item/EggItem.cpp index fd0c24c1a..1c7f3ed79 100644 --- a/targets/minecraft/world/item/EggItem.cpp +++ b/targets/minecraft/world/item/EggItem.cpp @@ -22,7 +22,6 @@ std::shared_ptr EggItem::use( level->playEntitySound(player, eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); if (!level->isClientSide) - level->addEntity( - std::make_shared(level, player)); + level->addEntity(std::make_shared(level, player)); return instance; } diff --git a/targets/minecraft/world/item/EnchantedBookItem.cpp b/targets/minecraft/world/item/EnchantedBookItem.cpp index 6dd5b51c6..7b4504ef1 100644 --- a/targets/minecraft/world/item/EnchantedBookItem.cpp +++ b/targets/minecraft/world/item/EnchantedBookItem.cpp @@ -108,8 +108,7 @@ void EnchantedBookItem::addEnchantment(std::shared_ptr item, std::shared_ptr EnchantedBookItem::createForEnchantment( EnchantmentInstance* enchant) { - std::shared_ptr item = - std::make_shared(this); + std::shared_ptr item = std::make_shared(this); addEnchantment(item, enchant); return item; } @@ -128,8 +127,8 @@ std::shared_ptr EnchantedBookItem::createForRandomLoot( Enchantment::validEnchantments.size())]; std::shared_ptr book = std::make_shared(id, 1, 0); - int level = random->nextInt(enchantment->getMinLevel(), - enchantment->getMaxLevel()); + int level = + random->nextInt(enchantment->getMinLevel(), enchantment->getMaxLevel()); addEnchantment(book, new EnchantmentInstance(enchantment, level)); @@ -148,8 +147,8 @@ WeighedTreasure* EnchantedBookItem::createForRandomTreasure(Random* random, Enchantment::validEnchantments.size())]; std::shared_ptr book = std::make_shared(id, 1, 0); - int level = random->nextInt(enchantment->getMinLevel(), - enchantment->getMaxLevel()); + int level = + random->nextInt(enchantment->getMinLevel(), enchantment->getMaxLevel()); addEnchantment(book, new EnchantmentInstance(enchantment, level)); diff --git a/targets/minecraft/world/item/EnchantedBookItem.h b/targets/minecraft/world/item/EnchantedBookItem.h index d5e9a1071..018eb33ad 100644 --- a/targets/minecraft/world/item/EnchantedBookItem.h +++ b/targets/minecraft/world/item/EnchantedBookItem.h @@ -12,7 +12,8 @@ class CompoundTag; class Enchantment; class Random; class WeighedTreasure; -template class ListTag; +template +class ListTag; class EnchantedBookItem : public Item { public: diff --git a/targets/minecraft/world/item/FireworksChargeItem.cpp b/targets/minecraft/world/item/FireworksChargeItem.cpp index fe9fa7a52..8b6662599 100644 --- a/targets/minecraft/world/item/FireworksChargeItem.cpp +++ b/targets/minecraft/world/item/FireworksChargeItem.cpp @@ -94,7 +94,8 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag, } // colors - std::vector colorList = expTag->getIntArray(FireworksItem::TAG_E_COLORS); + std::vector colorList = + expTag->getIntArray(FireworksItem::TAG_E_COLORS); if (colorList.size() > 0) { bool first = true; std::wstring output = L""; @@ -124,7 +125,8 @@ void FireworksChargeItem::appendHoverText(CompoundTag* expTag, } // has fade? - std::vector fadeList = expTag->getIntArray(FireworksItem::TAG_E_FADECOLORS); + std::vector fadeList = + expTag->getIntArray(FireworksItem::TAG_E_FADECOLORS); if (fadeList.size() > 0) { bool first = true; std::wstring output = diff --git a/targets/minecraft/world/item/MapItem.cpp b/targets/minecraft/world/item/MapItem.cpp index 375659e57..b8c26b118 100644 --- a/targets/minecraft/world/item/MapItem.cpp +++ b/targets/minecraft/world/item/MapItem.cpp @@ -44,8 +44,7 @@ std::shared_ptr MapItem::getSavedData(short idNum, int aux = idNum; id = std::wstring(L"map_") + _toString(aux); - mapItemSavedData = - std::make_shared(id); + mapItemSavedData = std::make_shared(id); level->setSavedData(id, (std::shared_ptr)mapItemSavedData); } @@ -69,8 +68,7 @@ std::shared_ptr MapItem::getSavedData( // itemInstance->setAuxValue(level->getFreeAuxValueFor(L"map")); id = std::wstring(L"map_") + _toString(itemInstance->getAuxValue()); - mapItemSavedData = - std::make_shared(id); + mapItemSavedData = std::make_shared(id); newData = true; } @@ -304,13 +302,12 @@ std::shared_ptr MapItem::getUpdatePacket( std::shared_ptr itemInstance, Level* level, std::shared_ptr player) { std::vector data = MapItem::getSavedData(itemInstance, level) - ->getUpdatePacket(itemInstance, level, player); + ->getUpdatePacket(itemInstance, level, player); if (data.empty()) return nullptr; - std::shared_ptr retval = - std::make_shared( - (short)Item::map->id, (short)itemInstance->getAuxValue(), data); + std::shared_ptr retval = std::make_shared( + (short)Item::map->id, (short)itemInstance->getAuxValue(), data); return retval; } diff --git a/targets/minecraft/world/item/PlanterTileItem.cpp b/targets/minecraft/world/item/PlanterTileItem.cpp index fa6a69c9a..7844f6119 100644 --- a/targets/minecraft/world/item/PlanterTileItem.cpp +++ b/targets/minecraft/world/item/PlanterTileItem.cpp @@ -17,7 +17,7 @@ TilePlanterItem::TilePlanterItem(int id, Tile* tile) : Item(id) { } bool TilePlanterItem::useOn(std::shared_ptr instance, - std::shared_ptr player, Level* level, int x, + std::shared_ptr player, Level* level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, bool bTestUseOnOnly) { // 4J-PB - Adding a test only version to allow tooltips to be displayed diff --git a/targets/minecraft/world/item/SnowballItem.cpp b/targets/minecraft/world/item/SnowballItem.cpp index 876132839..ac5b9df8f 100644 --- a/targets/minecraft/world/item/SnowballItem.cpp +++ b/targets/minecraft/world/item/SnowballItem.cpp @@ -24,7 +24,6 @@ std::shared_ptr SnowballItem::use( eSoundType_RANDOM_BOW, 0.5f, 0.4f / (random->nextFloat() * 0.4f + 0.8f)); if (!level->isClientSide) - level->addEntity( - std::make_shared(level, player)); + level->addEntity(std::make_shared(level, player)); return instance; } \ No newline at end of file diff --git a/targets/minecraft/world/item/crafting/ArmorDyeRecipe.cpp b/targets/minecraft/world/item/crafting/ArmorDyeRecipe.cpp index 78faf552d..3404eb873 100644 --- a/targets/minecraft/world/item/crafting/ArmorDyeRecipe.cpp +++ b/targets/minecraft/world/item/crafting/ArmorDyeRecipe.cpp @@ -148,10 +148,10 @@ void ArmorDyeRecipe::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) { TempIngReq.iIngValA = new int[3 * 3]; TempIngReq.iIngAuxValA = new int[3 * 3]; - memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9); - memset(TempIngReq.iIngValA, 0, sizeof(int) * 9); + memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9); + memset(TempIngReq.iIngValA, 0, sizeof(int) * 9); memset(TempIngReq.iIngAuxValA, Recipes::ANY_AUX_VALUE, sizeof(int) * 9); - memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9); + memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9); pIngReq->iIngIDA = new int[TempIngReq.iIngC]; pIngReq->iIngValA = new int[TempIngReq.iIngC]; diff --git a/targets/minecraft/world/item/crafting/FireworksRecipe.cpp b/targets/minecraft/world/item/crafting/FireworksRecipe.cpp index fbac70caa..8626f6e64 100644 --- a/targets/minecraft/world/item/crafting/FireworksRecipe.cpp +++ b/targets/minecraft/world/item/crafting/FireworksRecipe.cpp @@ -100,8 +100,7 @@ bool FireworksRecipe::matches(std::shared_ptr craftSlots, // create fireworks if (sulphurCount >= 1 && paperCount == 1 && chargeComponents == 0) { - resultItem = - std::make_shared(Item::fireworks); + resultItem = std::make_shared(Item::fireworks); if (chargeCount > 0) { CompoundTag* itemTag = new CompoundTag(); CompoundTag* fireTag = @@ -201,13 +200,11 @@ bool FireworksRecipe::matches(std::shared_ptr craftSlots, CompoundTag* compound = resultItem->getTag()->getCompound(FireworksItem::TAG_EXPLOSION); if (compound == nullptr) { - setResultItem(resultItem); return false; } compound->putIntArray(FireworksItem::TAG_E_FADECOLORS, colorArray); } else { - setResultItem(resultItem); return false; } diff --git a/targets/minecraft/world/item/crafting/Recipes.cpp b/targets/minecraft/world/item/crafting/Recipes.cpp index cef9f8917..79093c42a 100644 --- a/targets/minecraft/world/item/crafting/Recipes.cpp +++ b/targets/minecraft/world/item/crafting/Recipes.cpp @@ -1205,7 +1205,8 @@ std::shared_ptr Recipes::getItemForRecipe(Recipy* r) { // 4J-PB - build the required ingredients for recipes void Recipes::buildRecipeIngredientsArray(void) { - // std::vector *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); + // std::vector *recipes = ((Recipes + // *)Recipes::getInstance())->getRecipies(); int iRecipeC = (int)recipies->size(); diff --git a/targets/minecraft/world/item/crafting/ShapedRecipy.cpp b/targets/minecraft/world/item/crafting/ShapedRecipy.cpp index 61a034f39..50a958054 100644 --- a/targets/minecraft/world/item/crafting/ShapedRecipy.cpp +++ b/targets/minecraft/world/item/crafting/ShapedRecipy.cpp @@ -129,10 +129,10 @@ void ShapedRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) { TempIngReq.iIngValA = new int[9]; TempIngReq.iIngAuxValA = new int[9]; - memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9); - memset(TempIngReq.iIngValA, 0, sizeof(int) * 9); + memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9); + memset(TempIngReq.iIngValA, 0, sizeof(int) * 9); memset(TempIngReq.iIngAuxValA, Recipes::ANY_AUX_VALUE, sizeof(int) * 9); - memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9); + memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9); for (int x = 0; x < 3; x++) { for (int y = 0; y < 3; y++) { diff --git a/targets/minecraft/world/item/crafting/ShapelessRecipy.cpp b/targets/minecraft/world/item/crafting/ShapelessRecipy.cpp index 4500a59dc..2b442a145 100644 --- a/targets/minecraft/world/item/crafting/ShapelessRecipy.cpp +++ b/targets/minecraft/world/item/crafting/ShapelessRecipy.cpp @@ -106,10 +106,10 @@ void ShapelessRecipy::collectRequirements(INGREDIENTS_REQUIRED* pIngReq) { TempIngReq.iIngValA = new int[3 * 3]; TempIngReq.iIngAuxValA = new int[3 * 3]; - memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9); - memset(TempIngReq.iIngValA, 0, sizeof(int) * 9); + memset(TempIngReq.iIngIDA, 0, sizeof(int) * 9); + memset(TempIngReq.iIngValA, 0, sizeof(int) * 9); memset(TempIngReq.iIngAuxValA, Recipes::ANY_AUX_VALUE, sizeof(int) * 9); - memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9); + memset(TempIngReq.uiGridA, 0, sizeof(unsigned int) * 9); auto citEnd = ingredients->end(); diff --git a/targets/minecraft/world/item/enchantment/Enchantment.cpp b/targets/minecraft/world/item/enchantment/Enchantment.cpp index d93730d62..4bd6e4448 100644 --- a/targets/minecraft/world/item/enchantment/Enchantment.cpp +++ b/targets/minecraft/world/item/enchantment/Enchantment.cpp @@ -7,7 +7,8 @@ #include "strings.h" // Enchantment *Enchantment::enchantments[256]; -std::vector Enchantment::enchantments = std::vector(256); +std::vector Enchantment::enchantments = + std::vector(256); std::vector Enchantment::validEnchantments; Enchantment* Enchantment::allDamageProtection = nullptr; diff --git a/targets/minecraft/world/item/enchantment/EnchantmentHelper.cpp b/targets/minecraft/world/item/enchantment/EnchantmentHelper.cpp index 3f79dd28e..61a4f6a0c 100644 --- a/targets/minecraft/world/item/enchantment/EnchantmentHelper.cpp +++ b/targets/minecraft/world/item/enchantment/EnchantmentHelper.cpp @@ -94,8 +94,8 @@ void EnchantmentHelper::setEnchantments( } } -int EnchantmentHelper::getEnchantmentLevel(int enchantmentId, - std::vector> inventory) { +int EnchantmentHelper::getEnchantmentLevel( + int enchantmentId, std::vector> inventory) { if (inventory.empty()) return 0; int bestLevel = 0; // for (ItemInstance piece : inventory) @@ -130,7 +130,8 @@ void EnchantmentHelper::runIterationOnItem( } void EnchantmentHelper::runIterationOnInventory( - EnchantmentIterationMethod& method, std::vector> inventory) { + EnchantmentIterationMethod& method, + std::vector> inventory) { // for (ItemInstance piece : inventory) for (unsigned int i = 0; i < inventory.size(); ++i) { runIterationOnItem(method, inventory[i]); @@ -152,8 +153,8 @@ EnchantmentHelper::GetDamageProtectionIteration * @param source * @return */ -int EnchantmentHelper::getDamageProtection(std::vector> armor, - DamageSource* source) { +int EnchantmentHelper::getDamageProtection( + std::vector> armor, DamageSource* source) { getDamageProtectionIteration.sum = 0; getDamageProtectionIteration.source = source; @@ -248,7 +249,8 @@ int EnchantmentHelper::getArmorThorns(std::shared_ptr source) { std::shared_ptr EnchantmentHelper::getRandomItemWith( Enchantment* enchantment, std::shared_ptr source) { - std::vector> items = source->getEquipmentSlots(); + std::vector> items = + source->getEquipmentSlots(); for (unsigned int i = 0; i < items.size(); ++i) { std::shared_ptr item = items[i]; if (item != nullptr && getEnchantmentLevel(enchantment->id, item) > 0) { diff --git a/targets/minecraft/world/item/enchantment/EnchantmentHelper.h b/targets/minecraft/world/item/enchantment/EnchantmentHelper.h index 9dfe70d8a..f7f5a8a23 100644 --- a/targets/minecraft/world/item/enchantment/EnchantmentHelper.h +++ b/targets/minecraft/world/item/enchantment/EnchantmentHelper.h @@ -24,8 +24,9 @@ public: static void setEnchantments(std::unordered_map* enchantments, std::shared_ptr item); - static int getEnchantmentLevel(int enchantmentId, - std::vector> inventory); + static int getEnchantmentLevel( + int enchantmentId, + std::vector> inventory); private: class EnchantmentIterationMethod { @@ -35,8 +36,9 @@ private: static void runIterationOnItem(EnchantmentIterationMethod& method, std::shared_ptr piece); - static void runIterationOnInventory(EnchantmentIterationMethod& method, - std::vector> inventory); + static void runIterationOnInventory( + EnchantmentIterationMethod& method, + std::vector> inventory); class GetDamageProtectionIteration : public EnchantmentIterationMethod { public: @@ -56,8 +58,8 @@ private: * @return */ public: - static int getDamageProtection(std::vector> armor, - DamageSource* source); + static int getDamageProtection( + std::vector> armor, DamageSource* source); private: class GetDamageBonusIteration : public EnchantmentIterationMethod { diff --git a/targets/minecraft/world/level/Explosion.cpp b/targets/minecraft/world/level/Explosion.cpp index 86ea9e629..90d301978 100644 --- a/targets/minecraft/world/level/Explosion.cpp +++ b/targets/minecraft/world/level/Explosion.cpp @@ -204,7 +204,7 @@ void Explosion::finalizeExplosion( if (destroyBlocks) { // toBlowArray.addAll(toBlow); // TODO 4J Stu - Reverse iterator - app.DebugPrintf("Finalizing explosion size %d\n", toBlow.size()); + app.DebugPrintf("Finalizing explosion size %d\n", toBlow.size()); static const int MAX_EXPLODE_PARTICLES = 50; // 4J - try and make at most MAX_EXPLODE_PARTICLES pairs of particles int fraction = (int)toBlowArray->size() / MAX_EXPLODE_PARTICLES; @@ -283,7 +283,6 @@ void Explosion::finalizeExplosion( } } - if (toBlowDirect == nullptr) delete toBlowArray; } diff --git a/targets/minecraft/world/level/Level.cpp b/targets/minecraft/world/level/Level.cpp index 3b52b3777..6ed976068 100644 --- a/targets/minecraft/world/level/Level.cpp +++ b/targets/minecraft/world/level/Level.cpp @@ -849,8 +849,6 @@ bool Level::setTileAndData(int x, int y, int z, int tile, int data, result = c->setTileAndData(x & 15, y, z & 15, tile, data); if (updateFlags != Tile::UPDATE_INVISIBLE_NO_LIGHT) { checkLight(x, y, z); - - } if (result) { if ((updateFlags & Tile::UPDATE_CLIENTS) != 0 && @@ -983,22 +981,18 @@ void Level::tileUpdated(int x, int y, int z, int tile) { } void Level::lightColumnChanged(int x, int z, int y0, int y1) { - if (y0 > y1) { + if (y0 > y1) { int tmp = y1; y1 = y0; y0 = tmp; } if (!dimension->hasCeiling) { - for (int y = y0; y <= y1; y++) { - checkLight(LightLayer::Sky, x, y, z); - + for (int y = y0; y <= y1; y++) { + checkLight(LightLayer::Sky, x, y, z); } - } - setTilesDirty(x, y0, z, x, y1, z); - - + setTilesDirty(x, y0, z, x, y1, z); } void Level::setTileDirty(int x, int y, int z) { @@ -1704,8 +1698,8 @@ void Level::removeListener(LevelListener* listener) { // 4J - added noEntities and blockAtEdge parameter std::vector* Level::getCubes(std::shared_ptr source, AABB* box, - bool noEntities /* = false*/, - bool blockAtEdge /* = false*/) { + bool noEntities /* = false*/, + bool blockAtEdge /* = false*/) { boxes.clear(); int x0 = Mth::floor(box->x0); int x1 = Mth::floor(box->x1 + 1); @@ -1791,7 +1785,8 @@ std::vector* Level::getCubes(std::shared_ptr source, AABB* box, // 4J Stu - Brought forward from 12w36 to fix #46282 - TU5: Gameplay: Exiting // the minecart in a tight corridor damages the player -std::vector* Level::getTileCubes(AABB* box, bool blockAtEdge /* = false */) { +std::vector* Level::getTileCubes(AABB* box, + bool blockAtEdge /* = false */) { return getCubes(nullptr, box, true, blockAtEdge); // boxes.clear(); // int x0 = Mth::floor(box->x0); @@ -2797,10 +2792,7 @@ void Level::setSpawnSettings(bool spawnEnemies, bool spawnFriendlies) { this->spawnFriendlies = spawnFriendlies; } -void Level::tick() { - tickWeather(); - -} +void Level::tick() { tickWeather(); } void Level::prepareWeather() { if (levelData->isRaining()) { @@ -3770,8 +3762,9 @@ std::shared_ptr Level::getPlayerByUUID(const std::wstring& name) { } // 4J Stu - Removed in 1.2.3 ? -std::vector Level::getBlocksAndData(int x, int y, int z, int xs, int ys, int zs, - bool includeLighting /* = true*/) { +std::vector Level::getBlocksAndData(int x, int y, int z, int xs, + int ys, int zs, + bool includeLighting /* = true*/) { std::vector result(xs * ys * zs * 5 / 2); int xc0 = x >> 4; int zc0 = z >> 4; @@ -3804,7 +3797,8 @@ std::vector Level::getBlocksAndData(int x, int y, int z, int xs, int ys // 4J Stu - Removed in 1.2.3 ? void Level::setBlocksAndData(int x, int y, int z, int xs, int ys, int zs, - std::vector& data, bool includeLighting /* = true*/) { + std::vector& data, + bool includeLighting /* = true*/) { int xc0 = x >> 4; int zc0 = z >> 4; int xc1 = (x + xs - 1) >> 4; @@ -3839,8 +3833,7 @@ void Level::setBlocksAndData(int x, int y, int z, int xs, int ys, int zs, } if (forceUnshare) { int size = (x1 - x0) * (y1 - y0) * (z1 - z0); - lc->stopSharingTilesAndData(); - + lc->stopSharingTilesAndData(); } if (p < data.size()) p = lc->setBlocksAndData(data, x0, y0, z0, x1, y1, z1, p, @@ -3848,10 +3841,9 @@ void Level::setBlocksAndData(int x, int y, int z, int xs, int ys, int zs, setTilesDirty(xc * 16 + x0, y0, zc * 16 + z0, xc * 16 + x1, y1, zc * 16 + z1); - if (g_NetworkManager.IsHost() && isClientSide) { + if (g_NetworkManager.IsHost() && isClientSide) { lc->startSharingTilesAndData(); } - } } } diff --git a/targets/minecraft/world/level/Level.h b/targets/minecraft/world/level/Level.h index 7bd0f60e2..9bf6b6a4b 100644 --- a/targets/minecraft/world/level/Level.h +++ b/targets/minecraft/world/level/Level.h @@ -89,8 +89,9 @@ public: static constexpr int MAX_LEVEL_SIZE = 30000000; static constexpr int maxMovementHeight = 512; // 4J added - static constexpr int minBuildHeight = 0; // 4J - brought forward from 1.2.3 - static constexpr int maxBuildHeight = 256; // 4J - brought forward from 1.2.3 + static constexpr int minBuildHeight = 0; // 4J - brought forward from 1.2.3 + static constexpr int maxBuildHeight = + 256; // 4J - brought forward from 1.2.3 static constexpr int genDepthBits = 7; static constexpr int genDepthBitsPlusFour = genDepthBits + 4; static constexpr int genDepth = 1 << genDepthBits; @@ -573,10 +574,11 @@ public: std::shared_ptr getPlayerByName(const std::wstring& name); std::shared_ptr getPlayerByUUID( const std::wstring& name); // 4J Added - std::vector getBlocksAndData(int x, int y, int z, int xs, int ys, int zs, - bool includeLighting = true); + std::vector getBlocksAndData(int x, int y, int z, int xs, int ys, + int zs, bool includeLighting = true); void setBlocksAndData(int x, int y, int z, int xs, int ys, int zs, - std::vector& data, bool includeLighting = true); + std::vector& data, + bool includeLighting = true); virtual void disconnect(bool sendDisconnect = true); void checkSession(); void setGameTime(int64_t time); diff --git a/targets/minecraft/world/level/MobSpawner.cpp b/targets/minecraft/world/level/MobSpawner.cpp index 4cf055837..6e4e7b353 100644 --- a/targets/minecraft/world/level/MobSpawner.cpp +++ b/targets/minecraft/world/level/MobSpawner.cpp @@ -41,7 +41,6 @@ std::unordered_map const int MobSpawner::tick(ServerLevel* level, bool spawnEnemies, bool spawnFriendlies, bool spawnPersistent) { - if (!spawnEnemies && !spawnFriendlies && !spawnPersistent) { return 0; } diff --git a/targets/minecraft/world/level/Region.cpp b/targets/minecraft/world/level/Region.cpp index b18fdf9f0..d60172d86 100644 --- a/targets/minecraft/world/level/Region.cpp +++ b/targets/minecraft/world/level/Region.cpp @@ -29,7 +29,8 @@ Region::Region(Level* level, int x1, int y1, int z1, int x2, int y2, int z2, int xc2 = (x2 + r) >> 4; int zc2 = (z2 + r) >> 4; - chunks = new std::vector>(xc2 - xc1 + 1, std::vector(zc2 - zc1 + 1, nullptr)); + chunks = new std::vector>( + xc2 - xc1 + 1, std::vector(zc2 - zc1 + 1, nullptr)); allEmpty = true; for (int xc = xc1; xc <= xc2; xc++) { @@ -174,7 +175,7 @@ int Region::getRawBrightness(int x, int y, int z, bool propagate) { int zc = (z >> 4) - zc1; return (*chunks)[xc][zc]->getRawBrightness(x & 15, y, z & 15, - level->skyDarken); + level->skyDarken); } int Region::getData(int x, int y, int z) { diff --git a/targets/minecraft/world/level/biome/BiomeCache.cpp b/targets/minecraft/world/level/biome/BiomeCache.cpp index c5af61e8a..d62042974 100644 --- a/targets/minecraft/world/level/biome/BiomeCache.cpp +++ b/targets/minecraft/world/level/biome/BiomeCache.cpp @@ -5,11 +5,11 @@ #include "Minecraft.Client/Linux/Linux_App.h" BiomeCache::Block::Block(int x, int z, BiomeCache* parent) { - // temps = std::vector(ZONE_SIZE * ZONE_SIZE, false); // MGH - - // added "no clear" flag to arrayWithLength downfall = + // temps = std::vector(ZONE_SIZE * ZONE_SIZE, false); + // // MGH - added "no clear" flag to arrayWithLength downfall = // std::vector(ZONE_SIZE - // * ZONE_SIZE, false); biomes = std::vector(ZONE_SIZE * ZONE_SIZE, - // false); + // * ZONE_SIZE, false); biomes = std::vector(ZONE_SIZE * + // ZONE_SIZE, false); biomeIndices = std::vector(ZONE_SIZE * ZONE_SIZE, false); lastUse = 0; @@ -27,8 +27,7 @@ BiomeCache::Block::Block(int x, int z, BiomeCache* parent) { (unsigned)z << ZONE_SIZE_BITS, ZONE_SIZE, ZONE_SIZE, false); } -BiomeCache::Block::~Block() { -} +BiomeCache::Block::~Block() {} Biome* BiomeCache::Block::getBiome(int x, int z) { // return biomes[(x & ZONE_SIZE_MASK) | ((z & ZONE_SIZE_MASK) << diff --git a/targets/minecraft/world/level/biome/BiomeDecorator.cpp b/targets/minecraft/world/level/biome/BiomeDecorator.cpp index 51702279a..3e7cc62b9 100644 --- a/targets/minecraft/world/level/biome/BiomeDecorator.cpp +++ b/targets/minecraft/world/level/biome/BiomeDecorator.cpp @@ -90,10 +90,9 @@ void BiomeDecorator::_init() { } void BiomeDecorator::decorate() { - decorateOres(); - + decorateOres(); - for (int i = 0; i < sandCount; i++) { + for (int i = 0; i < sandCount; i++) { int x = xo + random->nextInt(16) + 8; int z = zo + random->nextInt(16) + 8; sandFeature->place(level, random, x, level->getTopSolidBlock(x, z), z); @@ -110,9 +109,8 @@ void BiomeDecorator::decorate() { int z = zo + random->nextInt(16) + 8; sandFeature->place(level, random, x, level->getTopSolidBlock(x, z), z); } - - int forests = treeCount; + int forests = treeCount; if (random->nextInt(10) == 0) forests += 1; for (int i = 0; i < forests; i++) { @@ -123,9 +121,8 @@ void BiomeDecorator::decorate() { tree->place(level, random, x, level->getHeightmap(x, z), z); delete tree; } - - for (int i = 0; i < hugeMushrooms; i++) { + for (int i = 0; i < hugeMushrooms; i++) { int x = xo + random->nextInt(16) + 8; int z = zo + random->nextInt(16) + 8; hugeMushroomFeature->place(level, random, x, level->getHeightmap(x, z), @@ -156,7 +153,7 @@ void BiomeDecorator::decorate() { grassFeature->place(level, random, x, y, z); delete grassFeature; } - + // 4J Stu - For some reason this was created each time round in the loop // I assume there is a case where deadBushCount could be 0 DeadBushFeature* deadBushFeature = nullptr; @@ -240,8 +237,6 @@ void BiomeDecorator::decorate() { cactusFeature->place(level, random, x, y, z); } - - if (liquids) { // 4J Stu - For some reason this was created each time round in the loop SpringFeature* waterSpringFeature = new SpringFeature(Tile::water_Id); @@ -264,7 +259,6 @@ void BiomeDecorator::decorate() { } delete lavaSpringFeature; } - } void BiomeDecorator::decorate(int count, Feature* feature) { diff --git a/targets/minecraft/world/level/biome/BiomeSource.cpp b/targets/minecraft/world/level/biome/BiomeSource.cpp index 299e527fd..15ba20050 100644 --- a/targets/minecraft/world/level/biome/BiomeSource.cpp +++ b/targets/minecraft/world/level/biome/BiomeSource.cpp @@ -33,10 +33,10 @@ void BiomeSource::_init() { void BiomeSource::_init(int64_t seed, LevelType* generator) { _init(); - std::vector> layers = Layer::getDefaultLayers(seed, generator); + std::vector> layers = + Layer::getDefaultLayers(seed, generator); layer = layers[0]; zoomedLayer = layers[1]; - } BiomeSource::BiomeSource() { _init(); } @@ -66,7 +66,8 @@ float BiomeSource::getDownfall(int x, int z) const { // 4J - note that caller is responsible for deleting returned array. // temperatures array is for output only. -std::vector BiomeSource::getDownfallBlock(int x, int z, int w, int h) const { +std::vector BiomeSource::getDownfallBlock(int x, int z, int w, + int h) const { std::vector downfalls; getDownfallBlock(downfalls, x, z, w, h); return downfalls; @@ -75,8 +76,8 @@ std::vector BiomeSource::getDownfallBlock(int x, int z, int w, int h) con // 4J - note that caller is responsible for deleting returned array. // temperatures array is for output only. 4J - removal of separate temperature & // downfall layers brought forward from 1.2.3 -void BiomeSource::getDownfallBlock(std::vector& downfalls, int x, int z, int w, - int h) const { +void BiomeSource::getDownfallBlock(std::vector& downfalls, int x, int z, + int w, int h) const { // if (downfalls == nullptr || downfalls->length < w * h) if (downfalls.empty() || downfalls.size() < (unsigned int)(w * h)) { downfalls = std::vector(w * h); @@ -101,7 +102,8 @@ float BiomeSource::getTemperature(int x, int y, int z) const { // 4J - brought forward from 1.2.3 float BiomeSource::scaleTemp(float temp, int y) const { return temp; } -std::vector BiomeSource::getTemperatureBlock(int x, int z, int w, int h) const { +std::vector BiomeSource::getTemperatureBlock(int x, int z, int w, + int h) const { std::vector temperatures; getTemperatureBlock(temperatures, x, z, w, h); return temperatures; @@ -110,8 +112,8 @@ std::vector BiomeSource::getTemperatureBlock(int x, int z, int w, int h) // 4J - note that caller is responsible for deleting returned array. // temperatures array is for output only. 4J - removal of separate temperature & // downfall layers brought forward from 1.2.3 -void BiomeSource::getTemperatureBlock(std::vector& temperatures, int x, int z, - int w, int h) const { +void BiomeSource::getTemperatureBlock(std::vector& temperatures, int x, + int z, int w, int h) const { // if (temperatures == null || temperatures.size() < w * h) { if (temperatures.empty() || temperatures.size() < (unsigned int)(w * h)) { temperatures = std::vector(w * h); @@ -126,23 +128,24 @@ void BiomeSource::getTemperatureBlock(std::vector& temperatures, int x, i } } -std::vector BiomeSource::getRawBiomeBlock(int x, int z, int w, int h) const { +std::vector BiomeSource::getRawBiomeBlock(int x, int z, int w, + int h) const { std::vector biomes; getRawBiomeBlock(biomes, x, z, w, h); return biomes; } // 4J added -void BiomeSource::getRawBiomeIndices(std::vector& biomes, int x, int z, int w, - int h) const { +void BiomeSource::getRawBiomeIndices(std::vector& biomes, int x, int z, + int w, int h) const { std::vector result = layer->getArea(x, z, w, h); for (int i = 0; i < w * h; i++) { biomes[i] = result[i]; } } -void BiomeSource::getRawBiomeBlock(std::vector& biomes, int x, int z, int w, - int h) const { +void BiomeSource::getRawBiomeBlock(std::vector& biomes, int x, int z, + int w, int h) const { // if (biomes == null || biomes.size() < w * h) if (biomes.empty() || biomes.size() < (unsigned int)(w * h)) { biomes = std::vector(w * h); @@ -160,7 +163,8 @@ void BiomeSource::getRawBiomeBlock(std::vector& biomes, int x, int z, in } } -std::vector BiomeSource::getBiomeBlock(int x, int z, int w, int h) const { +std::vector BiomeSource::getBiomeBlock(int x, int z, int w, + int h) const { if (w == 16 && h == 16 && (x & 0xf) == 0 && (z & 0xf) == 0) { return cache->getBiomeBlockAt(x, z); } @@ -170,8 +174,8 @@ std::vector BiomeSource::getBiomeBlock(int x, int z, int w, int h) const } // 4J - caller is responsible for deleting biomes array -void BiomeSource::getBiomeBlock(std::vector& biomes, int x, int z, int w, int h, - bool useCache) const { +void BiomeSource::getBiomeBlock(std::vector& biomes, int x, int z, + int w, int h, bool useCache) const { // if (biomes == null || biomes.size() < w * h) if (biomes.empty() || biomes.size() < w * h) { biomes = std::vector(w * h); @@ -180,8 +184,8 @@ void BiomeSource::getBiomeBlock(std::vector& biomes, int x, int z, int w if (useCache && w == 16 && h == 16 && (x & 0xf) == 0 && (z & 0xf) == 0) { std::vector tmp = cache->getBiomeBlockAt(x, z); std::copy(tmp.begin(), tmp.begin() + w * h, biomes.begin()); - // the indices now. //4jcraft made it array delete - // return biomes; + // the indices now. //4jcraft made it array delete + // return biomes; } std::vector result = zoomedLayer->getArea(x, z, w, h); @@ -190,7 +194,8 @@ void BiomeSource::getBiomeBlock(std::vector& biomes, int x, int z, int w } } -std::vector BiomeSource::getBiomeIndexBlock(int x, int z, int w, int h) const { +std::vector BiomeSource::getBiomeIndexBlock(int x, int z, int w, + int h) const { if (w == 16 && h == 16 && (x & 0xf) == 0 && (z & 0xf) == 0) { return cache->getBiomeIndexBlockAt(x, z); } @@ -200,8 +205,8 @@ std::vector BiomeSource::getBiomeIndexBlock(int x, int z, int w, int h) } // 4J - caller is responsible for deleting biomes array -void BiomeSource::getBiomeIndexBlock(std::vector& biomeIndices, int x, int z, - int w, int h, bool useCache) const { +void BiomeSource::getBiomeIndexBlock(std::vector& biomeIndices, int x, + int z, int w, int h, bool useCache) const { // if (biomes == null || biomes.size() < w * h) if (biomeIndices.empty() || biomeIndices.size() < w * h) { biomeIndices = std::vector(w * h); @@ -312,7 +317,8 @@ TilePos* BiomeSource::findBiome(int x, int z, int r, Biome* toFind, * Returns null if the biome wasn't found */ TilePos* BiomeSource::findBiome(int x, int z, int r, - const std::vector& allowed, Random* random) { + const std::vector& allowed, + Random* random) { int x0 = ((x - r) >> 2); int z0 = ((z - r) >> 2); int x1 = ((x + r) >> 2); @@ -375,7 +381,8 @@ int64_t BiomeSource::findSeed(LevelType* generator) { static const int biomeOffset = -(biomeWidth / 2); // Storage for our biome indices - std::vector indices = std::vector(biomeWidth * biomeWidth); + std::vector indices = + std::vector(biomeWidth * biomeWidth); // Storage for the fractional amounts of each biome that will be // calculated @@ -412,8 +419,8 @@ int64_t BiomeSource::findSeed(LevelType* generator) { tryCount, bestSeed); BiomeSource* biomeSource = new BiomeSource(bestSeed); - std::vector biomes = biomeSource->getBiomeBlock(-27 * 16, -27 * 16, - 54 * 16, 54 * 16); + std::vector biomes = biomeSource->getBiomeBlock( + -27 * 16, -27 * 16, 54 * 16, 54 * 16); unsigned int* pixels = new unsigned int[54 * 16 * 54 * 16]; for (int i = 0; i < 54 * 16 * 54 * 16; i++) { diff --git a/targets/minecraft/world/level/biome/BiomeSource.h b/targets/minecraft/world/level/biome/BiomeSource.h index cf9b30baf..c18d6d2ee 100644 --- a/targets/minecraft/world/level/biome/BiomeSource.h +++ b/targets/minecraft/world/level/biome/BiomeSource.h @@ -33,7 +33,7 @@ public: BiomeSource(Level* level); private: - static bool getIsMatch(float* frac); // 4J added + static bool getIsMatch(float* frac); // 4J added static void getFracs(std::vector& indices, float* fracs); // 4J added public: static int64_t findSeed(LevelType* generator); // 4J added @@ -46,31 +46,36 @@ public: // 4J - changed the interface for these methods, mainly for thread safety virtual float getDownfall(int x, int z) const; - virtual std::vector getDownfallBlock(int x, int z, int w, int h) const; - virtual void getDownfallBlock(std::vector& downfalls, int x, int z, int w, - int h) const; + virtual std::vector getDownfallBlock(int x, int z, int w, + int h) const; + virtual void getDownfallBlock(std::vector& downfalls, int x, int z, + int w, int h) const; // 4J - changed the interface for these methods, mainly for thread safety virtual BiomeCache::Block* getBlockAt(int x, int y); virtual float getTemperature(int x, int y, int z) const; float scaleTemp(float temp, int y) const; // 4J - brought forward from 1.2.3 - virtual std::vector getTemperatureBlock(int x, int z, int w, int h) const; - virtual void getTemperatureBlock(std::vector& temperatures, int x, int z, - int w, int h) const; + virtual std::vector getTemperatureBlock(int x, int z, int w, + int h) const; + virtual void getTemperatureBlock(std::vector& temperatures, int x, + int z, int w, int h) const; - virtual std::vector getRawBiomeBlock(int x, int z, int w, int h) const; - virtual void getRawBiomeBlock(std::vector& biomes, int x, int z, int w, - int h) const; - virtual void getRawBiomeIndices(std::vector& biomes, int x, int z, int w, + virtual std::vector getRawBiomeBlock(int x, int z, int w, + int h) const; + virtual void getRawBiomeBlock(std::vector& biomes, int x, int z, + int w, int h) const; + virtual void getRawBiomeIndices(std::vector& biomes, int x, int z, + int w, int h) const; // 4J added virtual std::vector getBiomeBlock(int x, int z, int w, int h) const; - virtual void getBiomeBlock(std::vector& biomes, int x, int z, int w, int h, - bool useCache) const; + virtual void getBiomeBlock(std::vector& biomes, int x, int z, int w, + int h, bool useCache) const; - virtual std::vector getBiomeIndexBlock(int x, int z, int w, int h) const; - virtual void getBiomeIndexBlock(std::vector& biomeIndices, int x, int z, - int w, int h, bool useCache) const; + virtual std::vector getBiomeIndexBlock(int x, int z, int w, + int h) const; + virtual void getBiomeIndexBlock(std::vector& biomeIndices, int x, + int z, int w, int h, bool useCache) const; /** * Checks if an area around a block contains only the specified biomes. @@ -79,7 +84,8 @@ public: * This is a bit of a rough check, to make it as fast as possible. To ensure * NO other biomes, add a margin of at least four blocks to the radius */ - virtual bool containsOnly(int x, int z, int r, const std::vector& allowed); + virtual bool containsOnly(int x, int z, int r, + const std::vector& allowed); /** * Checks if an area around a block contains only the specified biome. @@ -105,7 +111,8 @@ public: * * Returns null if the biome wasn't found */ - virtual TilePos* findBiome(int x, int z, int r, const std::vector& allowed, + virtual TilePos* findBiome(int x, int z, int r, + const std::vector& allowed, Random* random); void update(); diff --git a/targets/minecraft/world/level/biome/FixedBiomeSource.cpp b/targets/minecraft/world/level/biome/FixedBiomeSource.cpp index c78c9cec9..b14bce51a 100644 --- a/targets/minecraft/world/level/biome/FixedBiomeSource.cpp +++ b/targets/minecraft/world/level/biome/FixedBiomeSource.cpp @@ -20,8 +20,8 @@ Biome* FixedBiomeSource::getBiome(int x, int z) { return biome; } float FixedBiomeSource::getTemperature(int x, int z) { return temperature; } -void FixedBiomeSource::getTemperatureBlock(std::vector& temperatures, int x, - int z, int w, int h) const { +void FixedBiomeSource::getTemperatureBlock(std::vector& temperatures, + int x, int z, int w, int h) const { if (temperatures.empty() || temperatures.size() < (unsigned int)(w * h)) { temperatures = std::vector(w * h); } @@ -30,7 +30,7 @@ void FixedBiomeSource::getTemperatureBlock(std::vector& temperatures, int } std::vector FixedBiomeSource::getTemperatureBlock(int x, int z, int w, - int h) const { + int h) const { std::vector temps(w * h); getTemperatureBlock(temps, x, z, w, h); return temps; @@ -38,15 +38,15 @@ std::vector FixedBiomeSource::getTemperatureBlock(int x, int z, int w, // 4J - note that caller is responsible for deleting returned array. // temperatures array is for output only. -void FixedBiomeSource::getTemperatureBlock(std::vector& temperatures, int x, - int z, int w, int h) const { +void FixedBiomeSource::getTemperatureBlock(std::vector& temperatures, + int x, int z, int w, int h) const { temperatures = std::vector(w * h); Arrays::fill(temperatures, 0, w * h, (double)temperature); } -void FixedBiomeSource::getDownfallBlock(std::vector& downfalls, int x, int z, - int w, int h) const { +void FixedBiomeSource::getDownfallBlock(std::vector& downfalls, int x, + int z, int w, int h) const { if (downfalls.empty() || downfalls.size() < (unsigned int)(w * h)) { downfalls = std::vector(w * h); } @@ -54,7 +54,7 @@ void FixedBiomeSource::getDownfallBlock(std::vector& downfalls, int x, in } std::vector FixedBiomeSource::getDownfallBlock(int x, int z, int w, - int h) const { + int h) const { std::vector downfalls(w * h); getDownfallBlock(downfalls, x, z, w, h); return downfalls; @@ -62,8 +62,8 @@ std::vector FixedBiomeSource::getDownfallBlock(int x, int z, int w, float FixedBiomeSource::getDownfall(int x, int z) const { return downfall; } -void FixedBiomeSource::getDownfallBlock(std::vector& downfalls, int x, int z, - int w, int h) { +void FixedBiomeSource::getDownfallBlock(std::vector& downfalls, int x, + int z, int w, int h) { if (downfalls.empty() || downfalls.size() < (unsigned int)(w * h)) { downfalls = std::vector(w * h); } @@ -72,8 +72,8 @@ void FixedBiomeSource::getDownfallBlock(std::vector& downfalls, int x, i // 4J - caller is responsible for deleting biomes array, plus any optional // arrays output if pointers are passed in (_temperatures, _downfalls) -void FixedBiomeSource::getBiomeBlock(std::vector& biomes, int x, int z, int w, - int h, bool useCache) const { +void FixedBiomeSource::getBiomeBlock(std::vector& biomes, int x, int z, + int w, int h, bool useCache) const { biomes = std::vector(w * h); Arrays::fill(biomes, 0, w * h, biome); @@ -81,8 +81,9 @@ void FixedBiomeSource::getBiomeBlock(std::vector& biomes, int x, int z, // 4J - caller is responsible for deleting biomes array, plus any optional // arrays output if pointers are passed in (_temperatures, _downfalls) -void FixedBiomeSource::getBiomeIndexBlock(std::vector& biomeIndices, int x, int z, - int w, int h, bool useCache) const { +void FixedBiomeSource::getBiomeIndexBlock(std::vector& biomeIndices, + int x, int z, int w, int h, + bool useCache) const { biomeIndices = std::vector(w * h); int biomeIndex = biome->id; Arrays::fill(biomeIndices, 0, w * h, biomeIndex); @@ -91,8 +92,8 @@ void FixedBiomeSource::getBiomeIndexBlock(std::vector& biomeIndices, in // 4J-PB added in from beyond 1.8.2 // 4J - caller is responsible for deleting biomes array, plus any optional // arrays output if pointers are passed in (_temperatures, _downfalls) -void FixedBiomeSource::getRawBiomeBlock(std::vector& biomes, int x, int z, int w, - int h) const { +void FixedBiomeSource::getRawBiomeBlock(std::vector& biomes, int x, + int z, int w, int h) const { biomes = std::vector(w * h); Arrays::fill(biomes, 0, w * h, biome); @@ -102,7 +103,7 @@ void FixedBiomeSource::getRawBiomeBlock(std::vector& biomes, int x, int // 4J - caller is responsible for deleting biomes array, plus any optional // arrays output if pointers are passed in (_temperatures, _downfalls) std::vector FixedBiomeSource::getRawBiomeBlock(int x, int z, int w, - int h) const { + int h) const { std::vector biomes; getRawBiomeBlock(biomes, x, z, w, h); return biomes; diff --git a/targets/minecraft/world/level/biome/FixedBiomeSource.h b/targets/minecraft/world/level/biome/FixedBiomeSource.h index e84470afe..fd17106cf 100644 --- a/targets/minecraft/world/level/biome/FixedBiomeSource.h +++ b/targets/minecraft/world/level/biome/FixedBiomeSource.h @@ -19,32 +19,37 @@ public: virtual Biome* getBiome(ChunkPos* cp); virtual Biome* getBiome(int x, int z); virtual float getTemperature(int x, int z); - virtual void getTemperatureBlock(std::vector& temperatures, int x, int z, - int w, int h) const; - virtual std::vector getTemperatureBlock(int x, int z, int w, int h) const; - virtual void getTemperatureBlock(std::vector& temperatures, int x, int z, - int w, int h) const; - virtual void getDownfallBlock(std::vector& downfalls, int x, int z, int w, - int h) const; - virtual std::vector getDownfallBlock(int x, int z, int w, int h) const; + virtual void getTemperatureBlock(std::vector& temperatures, int x, + int z, int w, int h) const; + virtual std::vector getTemperatureBlock(int x, int z, int w, + int h) const; + virtual void getTemperatureBlock(std::vector& temperatures, int x, + int z, int w, int h) const; + virtual void getDownfallBlock(std::vector& downfalls, int x, int z, + int w, int h) const; + virtual std::vector getDownfallBlock(int x, int z, int w, + int h) const; virtual float getDownfall(int x, int z) const; - virtual void getDownfallBlock(std::vector& downfalls, int x, int z, int w, - int h); - virtual void getBiomeBlock(std::vector& biomes, int x, int z, int w, int h, - bool useCache) const; - virtual void getBiomeIndexBlock(std::vector& biomeIndices, int x, int z, - int w, int h, bool useCache) const; + virtual void getDownfallBlock(std::vector& downfalls, int x, int z, + int w, int h); + virtual void getBiomeBlock(std::vector& biomes, int x, int z, int w, + int h, bool useCache) const; + virtual void getBiomeIndexBlock(std::vector& biomeIndices, int x, + int z, int w, int h, bool useCache) const; // 4J-PB added in from beyond 1.8.2 - virtual std::vector getRawBiomeBlock(int x, int z, int w, int h) const; - virtual void getRawBiomeBlock(std::vector& biomes, int x, int z, int w, - int h) const; + virtual std::vector getRawBiomeBlock(int x, int z, int w, + int h) const; + virtual void getRawBiomeBlock(std::vector& biomes, int x, int z, + int w, int h) const; //////////////////////////////////// virtual TilePos* findBiome(int x, int z, int r, Biome* toFind, Random* random); - virtual TilePos* findBiome(int x, int z, int r, const std::vector& allowed, + virtual TilePos* findBiome(int x, int z, int r, + const std::vector& allowed, Random* random); virtual bool containsOnly(int x, int z, int r, Biome* allowed); - virtual bool containsOnly(int x, int z, int r, const std::vector& allowed); + virtual bool containsOnly(int x, int z, int r, + const std::vector& allowed); }; diff --git a/targets/minecraft/world/level/biome/JungleBiome.cpp b/targets/minecraft/world/level/biome/JungleBiome.cpp index 026a459a3..9618925d4 100644 --- a/targets/minecraft/world/level/biome/JungleBiome.cpp +++ b/targets/minecraft/world/level/biome/JungleBiome.cpp @@ -60,7 +60,7 @@ Feature* JungleBiome::getGrassFeature(Random* random) { void JungleBiome::decorate(Level* level, Random* random, int xo, int zo) { Biome::decorate(level, random, xo, zo); - VinesFeature* vines = new VinesFeature(); + VinesFeature* vines = new VinesFeature(); for (int i = 0; i < 50; i++) { int x = xo + random->nextInt(16) + 8; @@ -68,5 +68,4 @@ void JungleBiome::decorate(Level* level, Random* random, int xo, int zo) { int z = zo + random->nextInt(16) + 8; vines->place(level, random, x, y, z); } - } \ No newline at end of file diff --git a/targets/minecraft/world/level/chunk/BlockReplacements.cpp b/targets/minecraft/world/level/chunk/BlockReplacements.cpp index 31fd7d1c8..a292589e1 100644 --- a/targets/minecraft/world/level/chunk/BlockReplacements.cpp +++ b/targets/minecraft/world/level/chunk/BlockReplacements.cpp @@ -3,7 +3,8 @@ #include "BlockReplacements.h" #include "minecraft/world/level/tile/Tile.h" -std::vector BlockReplacements::replacements = std::vector(256); +std::vector BlockReplacements::replacements = + std::vector(256); void BlockReplacements::staticCtor() { for (int i = 0; i < 256; i++) { diff --git a/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp b/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp index c90d9a3b5..5d09cf1ac 100644 --- a/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp +++ b/targets/minecraft/world/level/chunk/CompressedTileStorage.cpp @@ -49,7 +49,8 @@ CompressedTileStorage::CompressedTileStorage(CompressedTileStorage* copyFrom) { std::lock_guard lock(cs_write); allocatedSize = copyFrom->allocatedSize; if (allocatedSize > 0) { - indicesAndData = (unsigned char*)malloc(allocatedSize); //(unsigned char *)malloc(allocatedSize); + indicesAndData = (unsigned char*)malloc( + allocatedSize); //(unsigned char *)malloc(allocatedSize); memcpy(indicesAndData, copyFrom->indicesAndData, allocatedSize); } else { indicesAndData = nullptr; @@ -244,7 +245,8 @@ inline void CompressedTileStorage::getBlock(int* block, int x, int y, int z) { } // Set all tile values from a data array of length 32768 (128 x 16 x 16). -void CompressedTileStorage::setData(std::vector& dataIn, unsigned int inOffset) { +void CompressedTileStorage::setData(std::vector& dataIn, + unsigned int inOffset) { unsigned short _blockIndices[512]; std::lock_guard lock(cs_write); @@ -328,7 +330,8 @@ void CompressedTileStorage::setData(std::vector& dataIn, unsigned int i // type8 / chunkTotal); memToAlloc += 1024; // For the indices - unsigned char* newIndicesAndData = (unsigned char*)malloc(memToAlloc); //(unsigned char *)malloc( memToAlloc ); + unsigned char* newIndicesAndData = (unsigned char*)malloc( + memToAlloc); //(unsigned char *)malloc( memToAlloc ); unsigned char* pucData = newIndicesAndData + 1024; unsigned short usDataOffset = 0; unsigned short* newIndices = (unsigned short*)newIndicesAndData; @@ -669,8 +672,8 @@ void CompressedTileStorage::set(int x, int y, int z, int val) { // Sets a region of tile values with the data at offset position in the array // dataIn - external ordering compatible with java DataLayer -int CompressedTileStorage::setDataRegion(std::vector& dataIn, int x0, int y0, - int z0, int x1, int y1, int z1, +int CompressedTileStorage::setDataRegion(std::vector& dataIn, int x0, + int y0, int z0, int x1, int y1, int z1, int offset, tileUpdatedCallback callback, void* param, int yparam) { @@ -703,9 +706,9 @@ int CompressedTileStorage::setDataRegion(std::vector& dataIn, int x0, i } // Tests whether setting data would actually change anything -bool CompressedTileStorage::testSetDataRegion(std::vector& dataIn, int x0, int y0, - int z0, int x1, int y1, int z1, - int offset) { +bool CompressedTileStorage::testSetDataRegion(std::vector& dataIn, + int x0, int y0, int z0, int x1, + int y1, int z1, int offset) { unsigned char* pucIn = &dataIn.data()[offset]; for (int x = x0; x < x1; x++) { for (int z = z0; z < z1; z++) { @@ -721,9 +724,9 @@ bool CompressedTileStorage::testSetDataRegion(std::vector& dataIn, int // Updates the data at offset position dataInOut with a region of tile // information - external ordering compatible with java DataLayer -int CompressedTileStorage::getDataRegion(std::vector& dataInOut, int x0, int y0, - int z0, int x1, int y1, int z1, - int offset) { +int CompressedTileStorage::getDataRegion(std::vector& dataInOut, + int x0, int y0, int z0, int x1, int y1, + int z1, int offset) { unsigned char* pucOut = &dataInOut.data()[offset]; for (int x = x0; x < x1; x++) { for (int z = z0; z < z1; z++) { @@ -944,7 +947,8 @@ void CompressedTileStorage::compress(int upgradeBlock /*=-1*/) { // If we need to do something here, then lets allocate some memory if (needsCompressed) { memToAlloc += 1024; // For the indices - unsigned char* newIndicesAndData = (unsigned char*)malloc(memToAlloc); //(unsigned char *)malloc( memToAlloc ); + unsigned char* newIndicesAndData = (unsigned char*)malloc( + memToAlloc); //(unsigned char *)malloc( memToAlloc ); if (newIndicesAndData == nullptr) { uint32_t lastError = GetLastError(); MEMORYSTATUS memStatus; @@ -1205,12 +1209,13 @@ void CompressedTileStorage::write(DataOutputStream* dos) { // Write the rest of the data if (allocatedSize > 1024) { - std::vector dataWrapper(indicesAndData + 1024, - indicesAndData + allocatedSize); + std::vector dataWrapper( + indicesAndData + 1024, indicesAndData + allocatedSize); dos->write(dataWrapper); } } else { - std::vector wrapper(indicesAndData, indicesAndData + allocatedSize); + std::vector wrapper(indicesAndData, + indicesAndData + allocatedSize); dos->write(wrapper); } } diff --git a/targets/minecraft/world/level/chunk/CompressedTileStorage.h b/targets/minecraft/world/level/chunk/CompressedTileStorage.h index 41eefa494..9444c0260 100644 --- a/targets/minecraft/world/level/chunk/CompressedTileStorage.h +++ b/targets/minecraft/world/level/chunk/CompressedTileStorage.h @@ -5,7 +5,8 @@ class DataInputStream; class DataOutputStream; -template class XLockFreeStack; +template +class XLockFreeStack; // This class is used for the compressed storage of tile data. Unlike the // SparseLightingStorage class, data is split into 512 blocks of 4x4x4 tiles. @@ -134,17 +135,18 @@ public: typedef void (*tileUpdatedCallback)(int x, int y, int z, void* param, int yparam); int setDataRegion( - std::vector& dataIn, int x0, int y0, int z0, int x1, int y1, int z1, - int offset, tileUpdatedCallback callback, void* param, + std::vector& dataIn, int x0, int y0, int z0, int x1, int y1, + int z1, int offset, tileUpdatedCallback callback, void* param, int yparam); // Sets a region of tile values with the data at offset // position in the array dataIn - external ordering // compatible with java DataLayer - bool testSetDataRegion(std::vector& dataIn, int x0, int y0, int z0, int x1, - int y1, int z1, + bool testSetDataRegion(std::vector& dataIn, int x0, int y0, int z0, + int x1, int y1, int z1, int offset); // Tests whether setting data would // actually change anything int getDataRegion( - std::vector& dataInOut, int x0, int y0, int z0, int x1, int y1, int z1, + std::vector& dataInOut, int x0, int y0, int z0, int x1, int y1, + int z1, int offset); // Updates the data at offset position dataInOut with a // region of tile information - external ordering // compatible with java DataLayer diff --git a/targets/minecraft/world/level/chunk/DataLayer.cpp b/targets/minecraft/world/level/chunk/DataLayer.cpp index 9d7f33a7f..c43c915e5 100644 --- a/targets/minecraft/world/level/chunk/DataLayer.cpp +++ b/targets/minecraft/world/level/chunk/DataLayer.cpp @@ -10,7 +10,6 @@ DataLayer::DataLayer(std::vector& data, int depthBits) this->data = data; } - int DataLayer::get(int x, int y, int z) { int pos = (x << depthBitsPlusFour | z << depthBits | y); int slot = pos >> 1; diff --git a/targets/minecraft/world/level/chunk/EmptyLevelChunk.cpp b/targets/minecraft/world/level/chunk/EmptyLevelChunk.cpp index bac715976..dd67b42b5 100644 --- a/targets/minecraft/world/level/chunk/EmptyLevelChunk.cpp +++ b/targets/minecraft/world/level/chunk/EmptyLevelChunk.cpp @@ -17,7 +17,8 @@ EmptyLevelChunk::EmptyLevelChunk(Level* level, int x, int z) LevelChunk::sTerrainPostPostProcessed; } -EmptyLevelChunk::EmptyLevelChunk(Level* level, std::vector& blocks, int x, int z) +EmptyLevelChunk::EmptyLevelChunk(Level* level, std::vector& blocks, + int x, int z) : LevelChunk(level, blocks, x, z) { dontSave = true; // Set this as fully post-processed, so we don't try and run post-processing @@ -123,9 +124,9 @@ bool EmptyLevelChunk::shouldSave(bool force) { return false; } void EmptyLevelChunk::setBlocks(std::vector& newBlocks, int sub) {} -int EmptyLevelChunk::getBlocksAndData(std::vector& data, int x0, int y0, int z0, - int x1, int y1, int z1, int p, - bool includeLighting /* = true*/) { +int EmptyLevelChunk::getBlocksAndData(std::vector& data, int x0, + int y0, int z0, int x1, int y1, int z1, + int p, bool includeLighting /* = true*/) { int xs = x1 - x0; int ys = y1 - y0; int zs = z1 - z0; @@ -142,9 +143,9 @@ int EmptyLevelChunk::getBlocksAndData(std::vector& data, int x0, int y0 return len; } -int EmptyLevelChunk::setBlocksAndData(std::vector& data, int x0, int y0, int z0, - int x1, int y1, int z1, int p, - bool includeLighting /* = true*/) { +int EmptyLevelChunk::setBlocksAndData(std::vector& data, int x0, + int y0, int z0, int x1, int y1, int z1, + int p, bool includeLighting /* = true*/) { int xs = x1 - x0; int ys = y1 - y0; int zs = z1 - z0; @@ -157,9 +158,9 @@ int EmptyLevelChunk::setBlocksAndData(std::vector& data, int x0, int y0 } } -bool EmptyLevelChunk::testSetBlocksAndData(std::vector& data, int x0, int y0, - int z0, int x1, int y1, int z1, - int p) { +bool EmptyLevelChunk::testSetBlocksAndData(std::vector& data, int x0, + int y0, int z0, int x1, int y1, + int z1, int p) { return false; } diff --git a/targets/minecraft/world/level/chunk/EmptyLevelChunk.h b/targets/minecraft/world/level/chunk/EmptyLevelChunk.h index 24f55157b..61a813717 100644 --- a/targets/minecraft/world/level/chunk/EmptyLevelChunk.h +++ b/targets/minecraft/world/level/chunk/EmptyLevelChunk.h @@ -63,13 +63,16 @@ public: bool shouldSave(bool force); void setBlocks(std::vector& newBlocks, int sub); int getBlocksAndData( - std::vector& data, int x0, int y0, int z0, int x1, int y1, int z1, int p, + std::vector& data, int x0, int y0, int z0, int x1, int y1, + int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter int setBlocksAndData( - std::vector& data, int x0, int y0, int z0, int x1, int y1, int z1, int p, + std::vector& data, int x0, int y0, int z0, int x1, int y1, + int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter - bool testSetBlocksAndData(std::vector& data, int x0, int y0, int z0, int x1, - int y1, int z1, int p); // 4J added + bool testSetBlocksAndData(std::vector& data, int x0, int y0, + int z0, int x1, int y1, int z1, + int p); // 4J added Random* getRandom(int64_t l); bool isEmpty(); virtual void reSyncLighting() {}; // 4J added diff --git a/targets/minecraft/world/level/chunk/LevelChunk.cpp b/targets/minecraft/world/level/chunk/LevelChunk.cpp index 7acc3d193..e9df25aea 100644 --- a/targets/minecraft/world/level/chunk/LevelChunk.cpp +++ b/targets/minecraft/world/level/chunk/LevelChunk.cpp @@ -94,7 +94,6 @@ void LevelChunk::init(Level* level, int x, int z) { } } - lowestHeightmap = 256; inhabitedTime = 0; @@ -278,7 +277,6 @@ void LevelChunk::stopSharingTilesAndData() { return; } - // Changed to used compressed storage - these CTORs make deep copies of // the storage passed as a parameter lowerBlocks = new CompressedTileStorage(lowerBlocks); @@ -442,11 +440,9 @@ LevelChunk::~LevelChunk() { if (upperSkyLight) delete upperSkyLight; if (upperBlockLight) delete upperBlockLight; - for (int i = 0; i < ENTITY_BLOCKS_LENGTH; ++i) delete entityBlocks[i]; delete[] entityBlocks; - #if defined(_LARGE_WORLDS) delete m_unloadedEntitiesTag; #endif @@ -832,12 +828,11 @@ void LevelChunk::recalcHeight(int x, int yStart, int z) { } if (height < lowestHeightmap) lowestHeightmap = height; if (!level->dimension->hasCeiling) { - lightGap(xOffs - 1, zOffs, y1, y2); + lightGap(xOffs - 1, zOffs, y1, y2); lightGap(xOffs + 1, zOffs, y1, y2); lightGap(xOffs, zOffs - 1, y1, y2); lightGap(xOffs, zOffs + 1, y1, y2); lightGap(xOffs, zOffs, y1, y2); - } this->setUnsaved(true); @@ -896,8 +891,8 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) { if (old != 0 && !level->isClientSide) { Tile::tiles[old]->onRemoving(level, xOffs, y, zOffs, oldData); } - blocks->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, tile); - + blocks->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, tile); + if (old != 0) { if (!level->isClientSide) { Tile::tiles[old]->onRemove(level, xOffs, y, zOffs, old, oldData); @@ -905,8 +900,7 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) { level->removeTileEntity(xOffs, y, zOffs); } } - data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, _data); - + data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, _data); // 4J added - flag if something emissive is being added. This is used during // level creation to determine what chunks need extra lighting processing @@ -914,30 +908,27 @@ bool LevelChunk::setTileAndData(int x, int y, int z, int _tile, int _data) { emissiveAdded = true; } - // 4J - There isn't any point in recalculating heights or updating sky + // 4J - There isn't any point in recalculating heights or updating sky // lighting if this tile has the same light-blocking capabilities as the one // it is replacing if (Tile::lightBlock[tile & 0xff] != Tile::lightBlock[old & 0xff]) { if (!level->dimension->hasCeiling) { if (Tile::lightBlock[tile & 0xff] != 0) { if (y >= oldHeight) { - recalcHeight(x, y + 1, z); - + recalcHeight(x, y + 1, z); } } else { if (y == oldHeight - 1) { - recalcHeight(x, y, z); - + recalcHeight(x, y, z); } } } // level.updateLight(LightLayer.Carried, xOffs, y, zOffs, xOffs, y, // zOffs); - lightGaps(x, z); - + lightGaps(x, z); } - + data->set(x, y % Level::COMPRESSED_CHUNK_SECTION_HEIGHT, z, _data); if (_tile != 0) { if (!level->isClientSide) { @@ -1450,7 +1441,7 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter // 4J Stu - Save out entities to a cached format that won't // interfere with other systems m_unloadedEntitiesTag = new CompoundTag(); - ListTag* entityTags = new ListTag(); + ListTag* entityTags = new ListTag(); { std::lock_guard lock(m_csEntities); @@ -1472,9 +1463,8 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter } m_unloadedEntitiesTag->put(L"Entities", entityTags); - - ListTag* tileEntityTags = new ListTag(); + ListTag* tileEntityTags = new ListTag(); auto itEnd = tileEntities.end(); for (std::unordered_map, @@ -1490,7 +1480,6 @@ void LevelChunk::unload(bool unloadTileEntities) // 4J - added parameter tileEntities.clear(); m_unloadedEntitiesTag->put(L"TileEntities", tileEntityTags); - } } #endif @@ -1645,8 +1634,8 @@ bool LevelChunk::shouldSave(bool force) { return m_unsaved; } -int LevelChunk::getBlocksAndData(std::vector* data, int x0, int y0, int z0, - int x1, int y1, int z1, int p, +int LevelChunk::getBlocksAndData(std::vector* data, int x0, int y0, + int z0, int x1, int y1, int z1, int p, bool includeLighting /* = true*/) { int xs = x1 - x0; int ys = y1 - y0; @@ -1716,8 +1705,9 @@ int LevelChunk::getBlocksAndData(std::vector* data, int x0, int y0, int } // 4J added - return true if setBlocksAndData would change any blocks -bool LevelChunk::testSetBlocksAndData(std::vector& data, int x0, int y0, int z0, - int x1, int y1, int z1, int p) { +bool LevelChunk::testSetBlocksAndData(std::vector& data, int x0, + int y0, int z0, int x1, int y1, int z1, + int p) { bool changed = false; // 4J Stu - Added this because some "min" functions don't let us use our @@ -1745,8 +1735,8 @@ void LevelChunk::tileUpdatedCallback(int x, int y, int z, void* param, lc->level->checkLight(xx, yy, zz); } -int LevelChunk::setBlocksAndData(std::vector& data, int x0, int y0, int z0, int x1, - int y1, int z1, int p, +int LevelChunk::setBlocksAndData(std::vector& data, int x0, int y0, + int z0, int x1, int y1, int z1, int p, bool includeLighting /* = true*/) { // If includeLighting is set, then this is a full chunk's worth of data that // we are receiving on the client. We'll have made this chunk initially as @@ -2336,8 +2326,9 @@ int LevelChunk::getHighestNonEmptyY() { return highestNonEmptyY; } -std::vector LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z0, int xs, - int& ys, int zs) { +std::vector LevelChunk::getReorderedBlocksAndData(int x0, int y0, + int z0, int xs, + int& ys, int zs) { int highestNonEmpty = getHighestNonEmptyY(); ys = std::min(highestNonEmpty - y0, ys); @@ -2350,7 +2341,8 @@ std::vector LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z unsigned int tileCount = xs * ys * zs; unsigned int halfTileCount = tileCount / 2; - std::vector data = std::vector(tileCount + (3 * halfTileCount) + biomes.size()); + std::vector data = + std::vector(tileCount + (3 * halfTileCount) + biomes.size()); for (int x = 0; x < xs; x++) { for (int z = 0; z < zs; z++) { for (int y = 0; y < ys; y++) { @@ -2398,8 +2390,9 @@ std::vector LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z return data; - // std::vector rawBuffer = std::vector( Level::CHUNK_TILE_COUNT + (3* - // Level::HALF_CHUNK_TILE_COUNT) ); for( int x = 0; x < 16; x++ ) + // std::vector rawBuffer = std::vector( + // Level::CHUNK_TILE_COUNT + (3* Level::HALF_CHUNK_TILE_COUNT) ); for( int x + // = 0; x < 16; x++ ) //{ // for( int z = 0; z < 16; z++ ) // { @@ -2415,13 +2408,15 @@ std::vector LevelChunk::getReorderedBlocksAndData(int x0, int y0, int z // unsigned int offset = Level::CHUNK_TILE_COUNT; //// Don't bother reordering block data, block light or sky light as they /// don't seem to make much difference - // std::vector dataData = std::vector(rawBuffer.data()+offset, + // std::vector dataData = + // std::vector(rawBuffer.data()+offset, // Level::HALF_CHUNK_TILE_COUNT); lc->getDataData(dataData); offset += // Level::HALF_CHUNK_TILE_COUNT; std::vector blockLightData = - // std::vector(rawBuffer.data() + offset, Level::HALF_CHUNK_TILE_COUNT); offset + // std::vector(rawBuffer.data() + offset, + // Level::HALF_CHUNK_TILE_COUNT); offset // += Level::HALF_CHUNK_TILE_COUNT; std::vector skyLightData = - // std::vector(rawBuffer.data() + offset, Level::HALF_CHUNK_TILE_COUNT); - // lc->getBlockLightData(blockLightData); + // std::vector(rawBuffer.data() + offset, + // Level::HALF_CHUNK_TILE_COUNT); lc->getBlockLightData(blockLightData); // lc->getSkyLightData(skyLightData); // return rawBuffer; } diff --git a/targets/minecraft/world/level/chunk/LevelChunk.h b/targets/minecraft/world/level/chunk/LevelChunk.h index 78314ef73..594061af9 100644 --- a/targets/minecraft/world/level/chunk/LevelChunk.h +++ b/targets/minecraft/world/level/chunk/LevelChunk.h @@ -65,11 +65,12 @@ private: CompressedTileStorage* upperBlocks; // 128 - 255 public: bool isRenderChunkEmpty(int y); - void setBlockData(std::vector& data); // Set block data to that passed in in - // the input array of size 32768 - void getBlockData( - std::vector& data); // Sets data in passed in array of size 32768, from - // the block data in this chunk + void setBlockData( + std::vector& data); // Set block data to that passed in in + // the input array of size 32768 + void getBlockData(std::vector& + data); // Sets data in passed in array of size 32768, + // from the block data in this chunk int getBlocksAllocatedSize(int* count0, int* count1, int* count2, int* count4, int* count8); @@ -89,10 +90,12 @@ private: SparseDataStorage* lowerData; // 0 - 127 SparseDataStorage* upperData; // 128 - 255 public: - void setDataData(std::vector& data); // Set data to that passed in in the - // input array of size 32768 - void getDataData(std::vector& data); // Sets data in passed in array of size - // 16384, from the data in this chunk + void setDataData( + std::vector& data); // Set data to that passed in in the + // input array of size 32768 + void getDataData( + std::vector& data); // Sets data in passed in array of size + // 16384, from the data in this chunk // DataLayer *data; private: @@ -109,17 +112,20 @@ public: data); // Get a byte array of length 16384 ( 128 x 16 x 16 x 0.5 ), // containing sky light data. Ordering same as java version. void getBlockLightData( - std::vector& data); // Get a byte array of length 16384 ( 128 x 16 x 16 x - // 0.5 ), containing block light data. Ordering same - // as java version. + std::vector& + data); // Get a byte array of length 16384 ( 128 x 16 x 16 x + // 0.5 ), containing block light data. Ordering same + // as java version. void setSkyLightData( - std::vector& data); // Set sky light data to data passed in input byte - // array of length 16384. This data must be in - // original (java version) order + std::vector& + data); // Set sky light data to data passed in input byte + // array of length 16384. This data must be in + // original (java version) order void setBlockLightData( - std::vector& data); // Set block light data to data passed in input byte - // array of length 16384. This data must be in - // original (java version) order + std::vector& + data); // Set block light data to data passed in input byte + // array of length 16384. This data must be in + // original (java version) order void setSkyLightDataAllBright(); // Set sky light data to be all fully lit bool isLowerBlockStorageCompressed(); int isLowerBlockLightStorageCompressed(); @@ -271,15 +277,17 @@ public: virtual int countEntities(); virtual bool shouldSave(bool force); virtual int getBlocksAndData( - std::vector* data, int x0, int y0, int z0, int x1, int y1, int z1, int p, + std::vector* data, int x0, int y0, int z0, int x1, int y1, + int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter static void tileUpdatedCallback(int x, int y, int z, void* param, int yparam); // 4J added virtual int setBlocksAndData( - std::vector& data, int x0, int y0, int z0, int x1, int y1, int z1, int p, + std::vector& data, int x0, int y0, int z0, int x1, int y1, + int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter - virtual bool testSetBlocksAndData(std::vector& data, int x0, int y0, int z0, - int x1, int y1, int z1, + virtual bool testSetBlocksAndData(std::vector& data, int x0, + int y0, int z0, int x1, int y1, int z1, int p); // 4J added virtual void setCheckAllLight(); @@ -315,8 +323,8 @@ public: void compressBlocks(); // 4J added void compressData(); // 4J added int getHighestNonEmptyY(); - std::vector getReorderedBlocksAndData(int x, int y, int z, int xs, int& ys, - int zs); + std::vector getReorderedBlocksAndData(int x, int y, int z, int xs, + int& ys, int zs); static void reorderBlocksAndDataToXZY(int y0, int xs, int ys, int zs, std::vector* data); #if defined(LIGHT_COMPRESSION_STATS) diff --git a/targets/minecraft/world/level/chunk/ReadOnlyChunkCache.cpp b/targets/minecraft/world/level/chunk/ReadOnlyChunkCache.cpp index ac6a7524e..996e5b9dd 100644 --- a/targets/minecraft/world/level/chunk/ReadOnlyChunkCache.cpp +++ b/targets/minecraft/world/level/chunk/ReadOnlyChunkCache.cpp @@ -14,8 +14,6 @@ ReadOnlyChunkCache::ReadOnlyChunkCache(Level* level, ChunkStorage* storage) { ReadOnlyChunkCache::~ReadOnlyChunkCache() { for (unsigned int i = 0; i < chunks.size(); ++i) delete chunks[i]; - - } bool ReadOnlyChunkCache::hasChunk(int x, int z) { diff --git a/targets/minecraft/world/level/chunk/SparseDataStorage.cpp b/targets/minecraft/world/level/chunk/SparseDataStorage.cpp index 160f41fac..d3b13171b 100644 --- a/targets/minecraft/world/level/chunk/SparseDataStorage.cpp +++ b/targets/minecraft/world/level/chunk/SparseDataStorage.cpp @@ -125,7 +125,8 @@ SparseDataStorage::SparseDataStorage(SparseDataStorage* copyFrom) { // Set all data values from a data array of length 16384 (128 x 16 x 16 x 0.5). // Source data must have same order as original java game -void SparseDataStorage::setData(std::vector& dataIn, unsigned int inOffset) { +void SparseDataStorage::setData(std::vector& dataIn, + unsigned int inOffset) { // Original order is defined as: // pos = (x << 11 | z << 7 | y); // slot = pos >> 1; @@ -203,7 +204,8 @@ void SparseDataStorage::setData(std::vector& dataIn, unsigned int inOff // Gets all data values into an array of length 16384. Destination data will // have same order as original java game. -void SparseDataStorage::getData(std::vector& retArray, unsigned int retOffset) { +void SparseDataStorage::getData(std::vector& retArray, + unsigned int retOffset) { memset(retArray.data() + +retOffset, 0, 16384); unsigned char *planeIndices, *data; getPlaneIndicesAndData(&planeIndices, &data); @@ -303,10 +305,10 @@ void SparseDataStorage::set(int x, int y, int z, int val) { // packed in nyblles in this dimension, and the code didn't make any attempt to // unpack it. This behaviour is copied here for compatibility even though our // source data isn't packed this way. Returns size of data copied. -int SparseDataStorage::setDataRegion(std::vector& dataIn, int x0, int y0, int z0, - int x1, int y1, int z1, int offset, - tileUpdatedCallback callback, void* param, - int yparam) { +int SparseDataStorage::setDataRegion(std::vector& dataIn, int x0, + int y0, int z0, int x1, int y1, int z1, + int offset, tileUpdatedCallback callback, + void* param, int yparam) { // Actual setting of data happens when calling set method so no need to lock // here unsigned char* pucIn = &dataIn.data()[offset]; @@ -363,8 +365,8 @@ int SparseDataStorage::setDataRegion(std::vector& dataIn, int x0, int y // packed in nyblles in this dimension, and the code didn't make any attempt to // unpack it. This behaviour is copied here for compatibility even though our // source data isn't packed this way Returns size of data copied. -int SparseDataStorage::getDataRegion(std::vector& dataInOut, int x0, int y0, - int z0, int x1, int y1, int z1, +int SparseDataStorage::getDataRegion(std::vector& dataInOut, int x0, + int y0, int z0, int x1, int y1, int z1, int offset) { unsigned char* pucOut = &dataInOut.data()[offset]; for (int x = x0; x < x1; x++) { diff --git a/targets/minecraft/world/level/chunk/SparseDataStorage.h b/targets/minecraft/world/level/chunk/SparseDataStorage.h index 8ad23f943..762dc384b 100644 --- a/targets/minecraft/world/level/chunk/SparseDataStorage.h +++ b/targets/minecraft/world/level/chunk/SparseDataStorage.h @@ -57,7 +57,8 @@ class TileCompressData_SPU; class DataInputStream; class DataOutputStream; -template class XLockFreeStack; +template +class XLockFreeStack; class SparseDataStorage { friend class TileCompressData_SPU; @@ -90,13 +91,14 @@ public: typedef void (*tileUpdatedCallback)(int x, int y, int z, void* param, int yparam); int setDataRegion( - std::vector& dataIn, int x0, int y0, int z0, int x1, int y1, int z1, - int offset, tileUpdatedCallback callback, void* param, + std::vector& dataIn, int x0, int y0, int z0, int x1, int y1, + int z1, int offset, tileUpdatedCallback callback, void* param, int yparam); // Sets a region of data values with the data at offset // position in the array dataIn - external ordering // compatible with java DataLayer int getDataRegion( - std::vector& dataInOut, int x0, int y0, int z0, int x1, int y1, int z1, + std::vector& dataInOut, int x0, int y0, int z0, int x1, int y1, + int z1, int offset); // Updates the data at offset position dataInOut with a // region of data information - external ordering // compatible with java DataLayer diff --git a/targets/minecraft/world/level/chunk/SparseLightStorage.cpp b/targets/minecraft/world/level/chunk/SparseLightStorage.cpp index f744ab814..ce8fd0343 100644 --- a/targets/minecraft/world/level/chunk/SparseLightStorage.cpp +++ b/targets/minecraft/world/level/chunk/SparseLightStorage.cpp @@ -126,7 +126,8 @@ SparseLightStorage::SparseLightStorage(SparseLightStorage* copyFrom) { // Set all lighting values from a data array of length 16384 (128 x 16 x 16 x // 0.5). Source data must have same order as original java game -void SparseLightStorage::setData(std::vector& dataIn, unsigned int inOffset) { +void SparseLightStorage::setData(std::vector& dataIn, + unsigned int inOffset) { // Original order is defined as: // pos = (x << 11 | z << 7 | y); // slot = pos >> 1; @@ -205,7 +206,8 @@ void SparseLightStorage::setData(std::vector& dataIn, unsigned int inOf // Gets all lighting values into an array of length 16384. Destination data will // have same order as original java game. -void SparseLightStorage::getData(std::vector& retArray, unsigned int retOffset) { +void SparseLightStorage::getData(std::vector& retArray, + unsigned int retOffset) { memset(retArray.data() + retOffset, 0, 16384); unsigned char *planeIndices, *data; getPlaneIndicesAndData(&planeIndices, &data); @@ -332,8 +334,9 @@ void SparseLightStorage::setAllBright() { // code didn't make any attempt to unpack it. This behaviour is copied here for // compatibility even though our source data isn't packed this way. Returns size // of data copied. -int SparseLightStorage::setDataRegion(std::vector& dataIn, int x0, int y0, int z0, - int x1, int y1, int z1, int offset) { +int SparseLightStorage::setDataRegion(std::vector& dataIn, int x0, + int y0, int z0, int x1, int y1, int z1, + int offset) { // Actual setting of data happens when calling set method so no need to lock // here unsigned char* pucIn = &dataIn.data()[offset]; @@ -364,8 +367,8 @@ int SparseLightStorage::setDataRegion(std::vector& dataIn, int x0, int // packed in nyblles in this dimension, and the code didn't make any attempt to // unpack it. This behaviour is copied here for compatibility even though our // source data isn't packed this way Returns size of data copied. -int SparseLightStorage::getDataRegion(std::vector& dataInOut, int x0, int y0, - int z0, int x1, int y1, int z1, +int SparseLightStorage::getDataRegion(std::vector& dataInOut, int x0, + int y0, int z0, int x1, int y1, int z1, int offset) { unsigned char* pucOut = &dataInOut.data()[offset]; for (int x = x0; x < x1; x++) { diff --git a/targets/minecraft/world/level/chunk/SparseLightStorage.h b/targets/minecraft/world/level/chunk/SparseLightStorage.h index b49610d2c..01a56038b 100644 --- a/targets/minecraft/world/level/chunk/SparseLightStorage.h +++ b/targets/minecraft/world/level/chunk/SparseLightStorage.h @@ -59,7 +59,8 @@ class TileCompressData_SPU; class DataInputStream; class DataOutputStream; -template class XLockFreeStack; +template +class XLockFreeStack; class SparseLightStorage { friend class TileCompressData_SPU; @@ -92,12 +93,14 @@ public: void set(int x, int y, int z, int val); // Set an individual lighting value void setAllBright(); // Set all lighting values to fully bright int setDataRegion( - std::vector& dataIn, int x0, int y0, int z0, int x1, int y1, int z1, + std::vector& dataIn, int x0, int y0, int z0, int x1, int y1, + int z1, int offset); // Sets a region of lighting values with the data at // offset position in the array dataIn - external ordering // compatible with java DataLayer int getDataRegion( - std::vector& dataInOut, int x0, int y0, int z0, int x1, int y1, int z1, + std::vector& dataInOut, int x0, int y0, int z0, int x1, int y1, + int z1, int offset); // Updates the data at offset position dataInOut with a // region of lighting information - external ordering // compatible with java DataLayer diff --git a/targets/minecraft/world/level/chunk/WaterLevelChunk.cpp b/targets/minecraft/world/level/chunk/WaterLevelChunk.cpp index aab0e6790..68df20824 100644 --- a/targets/minecraft/world/level/chunk/WaterLevelChunk.cpp +++ b/targets/minecraft/world/level/chunk/WaterLevelChunk.cpp @@ -6,7 +6,8 @@ class Entity; -WaterLevelChunk::WaterLevelChunk(Level* level, std::vector& blocks, int x, int z) +WaterLevelChunk::WaterLevelChunk(Level* level, std::vector& blocks, + int x, int z) : LevelChunk(level, blocks, x, z) { dontSave = true; // Set this as fully post-processed, so we don't try and run post-processing @@ -85,9 +86,9 @@ bool WaterLevelChunk::shouldSave(bool force) { return false; } void WaterLevelChunk::setBlocks(std::vector& newBlocks, int sub) {} -int WaterLevelChunk::setBlocksAndData(std::vector& data, int x0, int y0, int z0, - int x1, int y1, int z1, int p, - bool includeLighting /* = true*/) { +int WaterLevelChunk::setBlocksAndData(std::vector& data, int x0, + int y0, int z0, int x1, int y1, int z1, + int p, bool includeLighting /* = true*/) { int xs = x1 - x0; int ys = y1 - y0; int zs = z1 - z0; @@ -101,9 +102,9 @@ int WaterLevelChunk::setBlocksAndData(std::vector& data, int x0, int y0 } } -bool WaterLevelChunk::testSetBlocksAndData(std::vector& data, int x0, int y0, - int z0, int x1, int y1, int z1, - int p) { +bool WaterLevelChunk::testSetBlocksAndData(std::vector& data, int x0, + int y0, int z0, int x1, int y1, + int z1, int p) { return false; } diff --git a/targets/minecraft/world/level/chunk/WaterLevelChunk.h b/targets/minecraft/world/level/chunk/WaterLevelChunk.h index e3868972f..e72dbbf1b 100644 --- a/targets/minecraft/world/level/chunk/WaterLevelChunk.h +++ b/targets/minecraft/world/level/chunk/WaterLevelChunk.h @@ -54,10 +54,11 @@ public: bool shouldSave(bool force); void setBlocks(std::vector& newBlocks, int sub); int setBlocksAndData( - std::vector& data, int x0, int y0, int z0, int x1, int y1, int z1, int p, + std::vector& data, int x0, int y0, int z0, int x1, int y1, + int z1, int p, bool includeLighting = true); // 4J - added includeLighting parameter; - bool testSetBlocksAndData(std::vector& data, int x0, int y0, int z0, int x1, - int y1, int z1, int p); + bool testSetBlocksAndData(std::vector& data, int x0, int y0, + int z0, int x1, int y1, int z1, int p); Random* getRandom(int64_t l); virtual Biome* getBiome(int x, int z, BiomeSource* biomeSource); virtual void reSyncLighting() {}; // 4J added diff --git a/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp b/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp index 5aed2f7e2..3aa2d3666 100644 --- a/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp +++ b/targets/minecraft/world/level/chunk/storage/McRegionChunkStorage.cpp @@ -202,45 +202,40 @@ void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) { // running saves on multiple threads these sections have a lot of // contention. Better to let each thread have its turn at a higher level of // granularity. - DataOutputStream* output = RegionFileCache::getChunkDataOutputStream( + DataOutputStream* output = RegionFileCache::getChunkDataOutputStream( m_saveFile, m_prefix, levelChunk->x, levelChunk->z); - if (m_saveFile->getOriginalSaveVersion() >= SAVE_FILE_VERSION_COMPRESSED_CHUNK_STORAGE) { - OldChunkStorage::save(levelChunk, level, output); - + OldChunkStorage::save(levelChunk, level, output); - { + { std::lock_guard lock(cs_memory); s_chunkDataQueue.push_back(output); } - + } else { CompoundTag* tag; { std::lock_guard lock(cs_memory); - tag = new CompoundTag(); + tag = new CompoundTag(); CompoundTag* levelData = new CompoundTag(); tag->put(L"Level", levelData); OldChunkStorage::save(levelChunk, level, levelData); - - NbtIo::write(tag, output); - + + NbtIo::write(tag, output); } - output->close(); - + output->close(); // 4J Stu - getChunkDataOutputStream makes a new DataOutputStream that // points to a new ChunkBuffer( ByteArrayOutputStream ) We should clean // these up when we are done { std::lock_guard lock(cs_memory); - output->deleteChildStream(); + output->deleteChildStream(); delete output; delete tag; } - } LevelData* levelInfo = level->getLevelData(); @@ -258,11 +253,10 @@ void McRegionChunkStorage::save(Level* level, LevelChunk* levelChunk) { void McRegionChunkStorage::saveEntities(Level* level, LevelChunk* levelChunk) { #if defined(SPLIT_SAVES) - // 4j added cast to unsigned and changed index to u + // 4j added cast to unsigned and changed index to u uint64_t index = ((uint64_t)(uint32_t)(levelChunk->x) << 32) | (((uint64_t)(uint32_t)(levelChunk->z))); - CompoundTag* newTag = new CompoundTag(); bool savedEntities = OldChunkStorage::saveEntities(levelChunk, level, newTag); @@ -283,7 +277,7 @@ void McRegionChunkStorage::saveEntities(Level* level, LevelChunk* levelChunk) { } } delete newTag; - + #endif } @@ -308,22 +302,21 @@ void McRegionChunkStorage::tick() { m_saveFile->tick(); } void McRegionChunkStorage::flush() { #if defined(SPLIT_SAVES) - ConsoleSavePath currentFile = + ConsoleSavePath currentFile = ConsoleSavePath(m_prefix + std::wstring(L"entities.dat")); ConsoleSaveFileOutputStream fos = ConsoleSaveFileOutputStream(m_saveFile, currentFile); BufferedOutputStream bos(&fos, 1024 * 1024); DataOutputStream dos(&bos); - dos.writeInt(m_entityData.size()); + dos.writeInt(m_entityData.size()); for (auto it = m_entityData.begin(); it != m_entityData.end(); ++it) { dos.writeLong(it->first); dos.write(it->second, 0, it->second.size()); } bos.flush(); - - + #endif } @@ -373,11 +366,10 @@ int McRegionChunkStorage::runSaveThreadProc(void* lpParam) { lock.unlock(); if (dos) { - // app.DebugPrintf("Compressing chunk data (%d left)\n", + // app.DebugPrintf("Compressing chunk data (%d left)\n", // lastQueueSize - 1); dos->close(); dos->deleteChildStream(); - } delete dos; dos = nullptr; diff --git a/targets/minecraft/world/level/chunk/storage/OldChunkStorage.cpp b/targets/minecraft/world/level/chunk/storage/OldChunkStorage.cpp index 026caa47d..01c53f4ab 100644 --- a/targets/minecraft/world/level/chunk/storage/OldChunkStorage.cpp +++ b/targets/minecraft/world/level/chunk/storage/OldChunkStorage.cpp @@ -45,8 +45,7 @@ OldChunkStorage::ThreadStorage::ThreadStorage() { blockLightData = std::vector(Level::HALF_CHUNK_TILE_COUNT); } -OldChunkStorage::ThreadStorage::~ThreadStorage() { -} +OldChunkStorage::ThreadStorage::~ThreadStorage() {} void OldChunkStorage::CreateNewThreadStorage() { ThreadStorage* tls = new ThreadStorage(); @@ -246,26 +245,23 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, dos->writeLong(level->getGameTime()); dos->writeLong(lc->inhabitedTime); - lc->writeCompressedBlockData(dos); - + lc->writeCompressedBlockData(dos); - lc->writeCompressedDataData(dos); - + lc->writeCompressedDataData(dos); - lc->writeCompressedSkyLightData(dos); + lc->writeCompressedSkyLightData(dos); lc->writeCompressedBlockLightData(dos); - dos->write(lc->heightmap); dos->writeShort(lc->terrainPopulated); dos->write(lc->getBiomes()); - CompoundTag* tag = new CompoundTag(); + CompoundTag* tag = new CompoundTag(); #if !defined(SPLIT_SAVES) saveEntities(lc, level, tag); #endif - ListTag* tileEntityTags = new ListTag(); + ListTag* tileEntityTags = new ListTag(); auto itEnd = lc->tileEntities.end(); for (std::unordered_map, @@ -278,9 +274,8 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, tileEntityTags->add(teTag); } tag->put(L"TileEntities", tileEntityTags); - - std::vector* ticksInChunk = + std::vector* ticksInChunk = level->fetchTicksInChunk(lc, false); if (ticksInChunk != nullptr) { int64_t levelTime = level->getGameTime(); @@ -300,11 +295,9 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, tag->put(L"TileTicks", tickTags); } delete ticksInChunk; - NbtIo::write(tag, dos); delete tag; - } void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) { @@ -327,23 +320,20 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) { // moved to TLS ThreadStorage* tls = m_tlsStorage; - // static std::vector blockData = std::vector(32768); + // static std::vector blockData = std::vector(32768); lc->getBlockData(tls->blockData); tag->putByteArray(L"Blocks", tls->blockData); - - // static std::vector dataData = std::vector(16384); + // static std::vector dataData = std::vector(16384); lc->getDataData(tls->dataData); tag->putByteArray(L"Data", tls->dataData); - - // static std::vector skyLightData = std::vector(16384); + // static std::vector skyLightData = std::vector(16384); // static std::vector blockLightData = std::vector(16384); lc->getSkyLightData(tls->skyLightData); lc->getBlockLightData(tls->blockLightData); tag->putByteArray(L"SkyLight", tls->skyLightData); tag->putByteArray(L"BlockLight", tls->blockLightData); - tag->putByteArray(L"HeightMap", lc->heightmap); tag->putShort( @@ -354,11 +344,11 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) { std::vector biomeData = lc->getBiomes(); tag->putByteArray(L"Biomes", biomeData); - #if !defined(SPLIT_SAVES) +#if !defined(SPLIT_SAVES) saveEntities(lc, level, tag); #endif - ListTag* tileEntityTags = new ListTag(); + ListTag* tileEntityTags = new ListTag(); auto itEnd = lc->tileEntities.end(); for (std::unordered_map, @@ -371,9 +361,8 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) { tileEntityTags->add(teTag); } tag->put(L"TileEntities", tileEntityTags); - - std::vector* ticksInChunk = + std::vector* ticksInChunk = level->fetchTicksInChunk(lc, false); if (ticksInChunk != nullptr) { int64_t levelTime = level->getGameTime(); @@ -394,8 +383,6 @@ void OldChunkStorage::save(LevelChunk* lc, Level* level, CompoundTag* tag) { tag->put(L"TileTicks", tickTags); } delete ticksInChunk; - - } void OldChunkStorage::loadEntities(LevelChunk* lc, Level* level, @@ -427,7 +414,7 @@ void OldChunkStorage::loadEntities(LevelChunk* lc, Level* level, } LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) { - short version = dis->readShort(); + short version = dis->readShort(); int x = dis->readInt(); int z = dis->readInt(); int time = dis->readLong(); @@ -475,7 +462,7 @@ LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) { loadEntities(levelChunk, level, tag); if (tag->contains(L"TileTicks")) { - ListTag* tileTicks = + ListTag* tileTicks = (ListTag*)tag->getList(L"TileTicks"); if (tileTicks != nullptr) { @@ -488,13 +475,10 @@ LevelChunk* OldChunkStorage::load(Level* level, DataInputStream* dis) { teTag->getInt(L"t"), teTag->getInt(L"p")); } } - } delete tag; - - return levelChunk; } diff --git a/targets/minecraft/world/level/chunk/storage/RegionFile.cpp b/targets/minecraft/world/level/chunk/storage/RegionFile.cpp index a373b45f4..8b8243e90 100644 --- a/targets/minecraft/world/level/chunk/storage/RegionFile.cpp +++ b/targets/minecraft/world/level/chunk/storage/RegionFile.cpp @@ -69,7 +69,7 @@ RegionFile::RegionFile(ConsoleSaveFile* saveFile, File* path) { unsigned int numberOfBytesWritten = 0; unsigned int bytesToWrite = 0x1000 - (fileEntry->getFileSize() & 0xfff); std::uint8_t* zeroBytes = new std::uint8_t[bytesToWrite]; - memset(zeroBytes, 0, bytesToWrite); + memset(zeroBytes, 0, bytesToWrite); /* the file size is not a multiple of 4KB, grow it */ m_saveFile->writeFile(fileEntry, zeroBytes, bytesToWrite, @@ -271,8 +271,8 @@ DataInputStream* RegionFile::getChunkDataInputStream( // 4J - was InflaterInputStream in here too, but we've already decompressed std::vector decompData(decomp, decomp + readDecompLength); delete[] decomp; - DataInputStream* ret = new DataInputStream( - new ByteArrayInputStream(decompData)); + DataInputStream* ret = + new DataInputStream(new ByteArrayInputStream(decompData)); return ret; // } catch (IOException e) { @@ -337,7 +337,7 @@ void RegionFile::write(int x, int z, std::uint8_t* data, // better compressed until it is reused zero(sectorNumber, SECTOR_BYTES * sectorsAllocated); - /* scan for a free space large enough to store this chunk */ + /* scan for a free space large enough to store this chunk */ int runStart = (int)(find(sectorFree->begin(), sectorFree->end(), true) - sectorFree @@ -359,7 +359,6 @@ void RegionFile::write(int x, int z, std::uint8_t* data, } } } - if (runLength >= sectorsNeeded) { /* we found a free space large enough */ @@ -392,7 +391,6 @@ void RegionFile::write(int x, int z, std::uint8_t* data, write(sectorNumber, compData, length, compLength); setOffset(x, z, (sectorNumber << 8) | sectorsNeeded); - } } setTimestamp(x, z, (int)(System::currentTimeMillis() / 1000L)); @@ -454,7 +452,7 @@ void RegionFile::insertInitialSectors() { m_saveFile->setFilePointer(fileEntry, 0, SaveFileSeekOrigin::Begin); unsigned int numberOfBytesWritten = 0; std::uint8_t zeroBytes[SECTOR_BYTES]; - memset(zeroBytes, 0, SECTOR_BYTES); + memset(zeroBytes, 0, SECTOR_BYTES); /* we need to write the chunk offset table */ m_saveFile->writeFile(fileEntry, zeroBytes, SECTOR_BYTES, diff --git a/targets/minecraft/world/level/chunk/storage/ZoneFile.cpp b/targets/minecraft/world/level/chunk/storage/ZoneFile.cpp index a5e478916..85053fb99 100644 --- a/targets/minecraft/world/level/chunk/storage/ZoneFile.cpp +++ b/targets/minecraft/world/level/chunk/storage/ZoneFile.cpp @@ -50,7 +50,6 @@ ZoneFile::ZoneFile(int64_t key, File file, File entityFile) // } } - void ZoneFile::readHeader() { ZoneIo* zoneIo = new ZoneIo(channel, 0); ByteBuffer* bb = zoneIo->read(FILE_HEADER_SIZE); diff --git a/targets/minecraft/world/level/levelgen/CanyonFeature.cpp b/targets/minecraft/world/level/levelgen/CanyonFeature.cpp index 4de148dda..6d2de6f99 100644 --- a/targets/minecraft/world/level/levelgen/CanyonFeature.cpp +++ b/targets/minecraft/world/level/levelgen/CanyonFeature.cpp @@ -11,9 +11,10 @@ #include "minecraft/world/level/tile/Tile.h" void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs, - std::vector& blocks, double xCave, double yCave, - double zCave, float thickness, float yRot, - float xRot, int step, int dist, double yScale) { + std::vector& blocks, double xCave, + double yCave, double zCave, float thickness, + float yRot, float xRot, int step, int dist, + double yScale) { Random* random = new Random(seed); double xMid = xOffs * 16 + 8; double zMid = zOffs * 16 + 8; @@ -43,7 +44,8 @@ void CanyonFeature::addTunnel(int64_t seed, int xOffs, int zOffs, } for (; step < dist; step++) { - double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; + double rad = + 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; rad *= (random->nextFloat() * 0.25 + 0.75); diff --git a/targets/minecraft/world/level/levelgen/CanyonFeature.h b/targets/minecraft/world/level/levelgen/CanyonFeature.h index 6d4457466..136fb30dc 100644 --- a/targets/minecraft/world/level/levelgen/CanyonFeature.h +++ b/targets/minecraft/world/level/levelgen/CanyonFeature.h @@ -12,9 +12,10 @@ private: float rs[1024]; protected: - void addTunnel(int64_t seed, int xOffs, int zOffs, std::vector& blocks, - double xCave, double yCave, double zCave, float thickness, - float yRot, float xRot, int step, int dist, double yScale); + void addTunnel(int64_t seed, int xOffs, int zOffs, + std::vector& blocks, double xCave, double yCave, + double zCave, float thickness, float yRot, float xRot, + int step, int dist, double yScale); virtual void addFeature(Level* level, int x, int z, int xOffs, int zOffs, std::vector& blocks); }; diff --git a/targets/minecraft/world/level/levelgen/CustomLevelSource.cpp b/targets/minecraft/world/level/levelgen/CustomLevelSource.cpp index 8e8bd707b..e3fe50069 100644 --- a/targets/minecraft/world/level/levelgen/CustomLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/CustomLevelSource.cpp @@ -40,7 +40,8 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed, #if defined(_OVERRIDE_HEIGHTMAP) m_XZSize = level->getLevelData()->getXZSize(); - m_heightmapOverride = std::vector((m_XZSize * 16) * (m_XZSize * 16)); + m_heightmapOverride = + std::vector((m_XZSize * 16) * (m_XZSize * 16)); std::filesystem::path path = "GameRules/heightmap.bin"; std::ifstream file(path, std::ios::binary); @@ -53,14 +54,16 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed, app.DebugPrintf("Heightmap binary is too large!!\n"); __debugbreak(); } - file.read(reinterpret_cast(m_heightmapOverride.data()), static_cast(fileSize)); + file.read(reinterpret_cast(m_heightmapOverride.data()), + static_cast(fileSize)); if (!file) { app.FatalLoadError(); } } - m_waterheightOverride = std::vector((m_XZSize * 16) * (m_XZSize * 16)); + m_waterheightOverride = + std::vector((m_XZSize * 16) * (m_XZSize * 16)); std::filesystem::path waterHeightPath = "GameRules/waterheight.bin"; std::ifstream waterHeightFile(waterHeightPath, std::ios::binary); @@ -74,7 +77,9 @@ CustomLevelSource::CustomLevelSource(Level* level, int64_t seed, app.DebugPrintf("waterheight binary is too large!!\n"); __debugbreak(); } - waterHeightFile.read(reinterpret_cast(m_waterheightOverride.data()), static_cast(waterFileSize)); + waterHeightFile.read( + reinterpret_cast(m_waterheightOverride.data()), + static_cast(waterFileSize)); if (!waterHeightFile) { app.FatalLoadError(); @@ -111,7 +116,8 @@ CustomLevelSource::~CustomLevelSource() { #endif } -void CustomLevelSource::prepareHeights(int xOffs, int zOffs, std::vector& blocks) { +void CustomLevelSource::prepareHeights(int xOffs, int zOffs, + std::vector& blocks) { #if defined(_OVERRIDE_HEIGHTMAP) int xChunks = 16 / CHUNK_WIDTH; int yChunks = Level::maxBuildHeight / CHUNK_HEIGHT; @@ -232,7 +238,8 @@ void CustomLevelSource::prepareHeights(int xOffs, int zOffs, std::vector& blocks, +void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, + std::vector& blocks, std::vector& biomes) { #if defined(_OVERRIDE_HEIGHTMAP) int waterHeight = level->seaLevel; @@ -241,9 +248,9 @@ void CustomLevelSource::buildSurfaces(int xOffs, int zOffs, std::vector double s = 1 / 32.0; - std::vector depthBuffer(16 * - 16); // 4J - used to be declared with class level - // scope but moved here for thread safety + std::vector depthBuffer( + 16 * 16); // 4J - used to be declared with class level + // scope but moved here for thread safety depthBuffer = perlinNoise3->getRegion(depthBuffer, xOffs * 16, zOffs * 16, 0, 16, 16, 1, s * 2, s * 2, s * 2); @@ -355,8 +362,10 @@ LevelChunk* CustomLevelSource::getChunk(int xOffs, int zOffs) { int blocksSize = Level::maxBuildHeight * 16 * 16; uint8_t* tileData = (uint8_t*)malloc(blocksSize); memset(tileData, 0, blocksSize); - std::vector blocks = std::vector(tileData, tileData + blocksSize); - // std::vector blocks = std::vector(16 * level->depth * 16); + std::vector blocks = + std::vector(tileData, tileData + blocksSize); + // std::vector blocks = std::vector(16 * level->depth * + // 16); // LevelChunk *levelChunk = new LevelChunk(level, blocks, xOffs, zOffs); // // 4J - moved to below @@ -371,7 +380,6 @@ LevelChunk* CustomLevelSource::getChunk(int xOffs, int zOffs) { buildSurfaces(xOffs, zOffs, blocks, biomes); - caveFeature->apply(this, level, xOffs, zOffs, blocks); // 4J Stu Design Change - 1.8 gen goes stronghold, mineshaft, village, // canyon this changed in 1.2 to canyon, mineshaft, village, stronghold This @@ -511,15 +519,14 @@ void CustomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { bool hasVillage = false; - if (generateStructures) { + if (generateStructures) { mineShaftFeature->postProcess(level, pprandom, xt, zt); hasVillage = villageFeature->postProcess(level, pprandom, xt, zt); strongholdFeature->postProcess(level, pprandom, xt, zt); scatteredFeature->postProcess(level, random, xt, zt); } - - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { int x = xo + pprandom->nextInt(16) + 8; int y = pprandom->nextInt(Level::maxBuildHeight); int z = zo + pprandom->nextInt(16) + 8; @@ -528,10 +535,8 @@ void CustomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { } delete mrf; } - - biome->decorate(level, pprandom, xo, zo); - + biome->decorate(level, pprandom, xo, zo); app.processSchematics(parent->getChunk(xt, zt)); diff --git a/targets/minecraft/world/level/levelgen/DungeonFeature.cpp b/targets/minecraft/world/level/levelgen/DungeonFeature.cpp index 44c8fbf67..f9b4fca20 100644 --- a/targets/minecraft/world/level/levelgen/DungeonFeature.cpp +++ b/targets/minecraft/world/level/levelgen/DungeonFeature.cpp @@ -13,10 +13,11 @@ void DungeonFeature::addRoom(int xOffs, int zOffs, std::vector& blocks, 1 + random->nextFloat() * 6, 0, 0, -1, -1, 0.5); } -void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector& blocks, - double xCave, double yCave, double zCave, - float thickness, float yRot, float xRot, - int step, int dist, double yScale) { +void DungeonFeature::addTunnel(int xOffs, int zOffs, + std::vector& blocks, double xCave, + double yCave, double zCave, float thickness, + float yRot, float xRot, int step, int dist, + double yScale) { double xMid = xOffs * 16 + 8; double zMid = zOffs * 16 + 8; @@ -39,7 +40,8 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector& block bool steep = random->nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; + double rad = + 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; float xc = Mth::cos(xRot); @@ -65,11 +67,11 @@ void DungeonFeature::addTunnel(int xOffs, int zOffs, std::vector& block if (!singleStep && step == splitPoint && thickness > 1) { addTunnel(xOffs, zOffs, blocks, xCave, yCave, zCave, - random->nextFloat() * 0.5f + 0.5f, yRot - std::numbers::pi / 2, - xRot / 3, step, dist, 1.0); + random->nextFloat() * 0.5f + 0.5f, + yRot - std::numbers::pi / 2, xRot / 3, step, dist, 1.0); addTunnel(xOffs, zOffs, blocks, xCave, yCave, zCave, - random->nextFloat() * 0.5f + 0.5f, yRot + std::numbers::pi / 2, - xRot / 3, step, dist, 1.0); + random->nextFloat() * 0.5f + 0.5f, + yRot + std::numbers::pi / 2, xRot / 3, step, dist, 1.0); return; } if (!singleStep && random->nextInt(4) == 0) continue; diff --git a/targets/minecraft/world/level/levelgen/DungeonFeature.h b/targets/minecraft/world/level/levelgen/DungeonFeature.h index 076a066d6..98eb4bdc5 100644 --- a/targets/minecraft/world/level/levelgen/DungeonFeature.h +++ b/targets/minecraft/world/level/levelgen/DungeonFeature.h @@ -8,11 +8,11 @@ class Level; class DungeonFeature : public LargeFeature { - void addRoom(int xOffs, int zOffs, std::vector& blocks, double xRoom, - double yRoom, double zRoom); - void addTunnel(int xOffs, int zOffs, std::vector& blocks, double xCave, - double yCave, double zCave, float thickness, float yRot, - float xRot, int step, int dist, double yScale); + void addRoom(int xOffs, int zOffs, std::vector& blocks, + double xRoom, double yRoom, double zRoom); + void addTunnel(int xOffs, int zOffs, std::vector& blocks, + double xCave, double yCave, double zCave, float thickness, + float yRot, float xRot, int step, int dist, double yScale); virtual void addFeature(Level* level, int x, int z, int xOffs, int zOffs, std::vector& blocks); diff --git a/targets/minecraft/world/level/levelgen/FlatLevelSource.cpp b/targets/minecraft/world/level/levelgen/FlatLevelSource.cpp index 0c11228e3..43c112ffb 100644 --- a/targets/minecraft/world/level/levelgen/FlatLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/FlatLevelSource.cpp @@ -63,8 +63,10 @@ LevelChunk* FlatLevelSource::getChunk(int xOffs, int zOffs) { int chunksSize = Level::genDepth * 16 * 16; uint8_t* tileData = (uint8_t*)malloc(chunksSize); memset(tileData, 0, chunksSize); - std::vector blocks = std::vector(tileData, tileData + chunksSize); - // std::vector blocks = std::vector(16 * level->depth * 16); + std::vector blocks = + std::vector(tileData, tileData + chunksSize); + // std::vector blocks = std::vector(16 * level->depth * + // 16); prepareHeights(blocks); // LevelChunk *levelChunk = new LevelChunk(level, blocks, xOffs, zOffs); diff --git a/targets/minecraft/world/level/levelgen/HellFlatLevelSource.cpp b/targets/minecraft/world/level/levelgen/HellFlatLevelSource.cpp index 798a66fb4..aac138640 100644 --- a/targets/minecraft/world/level/levelgen/HellFlatLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/HellFlatLevelSource.cpp @@ -110,8 +110,10 @@ LevelChunk* HellFlatLevelSource::getChunk(int xOffs, int zOffs) { int chunksSize = Level::genDepth * 16 * 16; uint8_t* tileData = (uint8_t*)malloc(chunksSize); memset(tileData, 0, chunksSize); - std::vector blocks = std::vector(tileData, tileData + chunksSize); - // std::vector blocks = std::vector(16 * level->depth * 16); + std::vector blocks = + std::vector(tileData, tileData + chunksSize); + // std::vector blocks = std::vector(16 * level->depth * + // 16); prepareHeights(xOffs, zOffs, blocks); buildSurfaces(xOffs, zOffs, blocks); diff --git a/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp b/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp index 049b2be47..a2b180d04 100644 --- a/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/HellRandomLevelSource.cpp @@ -74,8 +74,9 @@ void HellRandomLevelSource::prepareHeights(int xOffs, int zOffs, int xSize = xChunks + 1; int ySize = Level::genDepth / CHUNK_HEIGHT + 1; int zSize = xChunks + 1; - std::vector buffer; // 4J - used to be declared with class level scope but - // tidying up for thread safety reasons + std::vector + buffer; // 4J - used to be declared with class level scope but + // tidying up for thread safety reasons buffer = getHeights(buffer, xOffs * xChunks, 0, zOffs * xChunks, xSize, ySize, zSize); @@ -161,9 +162,9 @@ void HellRandomLevelSource::buildSurfaces(int xOffs, int zOffs, double s = 1 / 32.0; - std::vector sandBuffer(16 * - 16); // 4J - used to be declared with class level - // scope but moved here for thread safety + std::vector sandBuffer( + 16 * 16); // 4J - used to be declared with class level + // scope but moved here for thread safety std::vector gravelBuffer(16 * 16); std::vector depthBuffer(16 * 16); @@ -308,8 +309,10 @@ LevelChunk* HellRandomLevelSource::getChunk(int xOffs, int zOffs) { int blocksSize = Level::genDepth * 16 * 16; uint8_t* tileData = (uint8_t*)malloc(blocksSize); memset(tileData, 0, blocksSize); - std::vector blocks = std::vector(tileData, tileData + blocksSize); - // std::vector blocks = std::vector(16 * level->depth * 16); + std::vector blocks = + std::vector(tileData, tileData + blocksSize); + // std::vector blocks = std::vector(16 * level->depth * + // 16); prepareHeights(xOffs, zOffs, blocks); buildSurfaces(xOffs, zOffs, blocks); @@ -339,9 +342,9 @@ void HellRandomLevelSource::lightChunk(LevelChunk* lc) { lc->recalcHeightmap(); } -std::vector HellRandomLevelSource::getHeights(std::vector& buffer, int x, int y, - int z, int xSize, int ySize, - int zSize) { +std::vector HellRandomLevelSource::getHeights( + std::vector& buffer, int x, int y, int z, int xSize, int ySize, + int zSize) { if (buffer.empty()) { buffer = std::vector(xSize * ySize * zSize); } @@ -437,7 +440,6 @@ std::vector HellRandomLevelSource::getHeights(std::vector& buffe } } - return buffer; } diff --git a/targets/minecraft/world/level/levelgen/HellRandomLevelSource.h b/targets/minecraft/world/level/levelgen/HellRandomLevelSource.h index e86eca29f..100a330e9 100644 --- a/targets/minecraft/world/level/levelgen/HellRandomLevelSource.h +++ b/targets/minecraft/world/level/levelgen/HellRandomLevelSource.h @@ -68,8 +68,8 @@ public: virtual void lightChunk(LevelChunk* lc); // 4J added private: - std::vector getHeights(std::vector& buffer, int x, int y, int z, int xSize, - int ySize, int zSize); + std::vector getHeights(std::vector& buffer, int x, int y, + int z, int xSize, int ySize, int zSize); public: bool hasChunk(int x, int y); diff --git a/targets/minecraft/world/level/levelgen/LargeCaveFeature.cpp b/targets/minecraft/world/level/levelgen/LargeCaveFeature.cpp index 4f79670f3..cd9115254 100644 --- a/targets/minecraft/world/level/levelgen/LargeCaveFeature.cpp +++ b/targets/minecraft/world/level/levelgen/LargeCaveFeature.cpp @@ -9,16 +9,16 @@ #include "minecraft/world/level/tile/Tile.h" void LargeCaveFeature::addRoom(int64_t seed, int xOffs, int zOffs, - std::vector& blocks, double xRoom, double yRoom, - double zRoom) { + std::vector& blocks, double xRoom, + double yRoom, double zRoom) { addTunnel(seed, xOffs, zOffs, blocks, xRoom, yRoom, zRoom, 1 + random->nextFloat() * 6, 0, 0, -1, -1, 0.5); } void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, - std::vector& blocks, double xCave, double yCave, - double zCave, float thickness, float yRot, - float xRot, int step, int dist, + std::vector& blocks, double xCave, + double yCave, double zCave, float thickness, + float yRot, float xRot, int step, int dist, double yScale) { double xMid = xOffs * 16 + 8; double zMid = zOffs * 16 + 8; @@ -42,7 +42,8 @@ void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, bool steep = random.nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; + double rad = + 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; float xc = Mth::cos(xRot); @@ -68,11 +69,11 @@ void LargeCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, if (!singleStep && step == splitPoint && thickness > 1 && dist > 0) { addTunnel(random.nextLong(), xOffs, zOffs, blocks, xCave, yCave, - zCave, random.nextFloat() * 0.5f + 0.5f, yRot - std::numbers::pi / 2, - xRot / 3, step, dist, 1.0); + zCave, random.nextFloat() * 0.5f + 0.5f, + yRot - std::numbers::pi / 2, xRot / 3, step, dist, 1.0); addTunnel(random.nextLong(), xOffs, zOffs, blocks, xCave, yCave, - zCave, random.nextFloat() * 0.5f + 0.5f, yRot + std::numbers::pi / 2, - xRot / 3, step, dist, 1.0); + zCave, random.nextFloat() * 0.5f + 0.5f, + yRot + std::numbers::pi / 2, xRot / 3, step, dist, 1.0); return; } if (!singleStep && random.nextInt(4) == 0) continue; diff --git a/targets/minecraft/world/level/levelgen/LargeCaveFeature.h b/targets/minecraft/world/level/levelgen/LargeCaveFeature.h index 47d48aba9..e7450ff4f 100644 --- a/targets/minecraft/world/level/levelgen/LargeCaveFeature.h +++ b/targets/minecraft/world/level/levelgen/LargeCaveFeature.h @@ -8,11 +8,13 @@ class LargeCaveFeature : public LargeFeature { protected: - void addRoom(int64_t seed, int xOffs, int zOffs, std::vector& blocks, - double xRoom, double yRoom, double zRoom); - void addTunnel(int64_t seed, int xOffs, int zOffs, std::vector& blocks, - double xCave, double yCave, double zCave, float thickness, - float yRot, float xRot, int step, int dist, double yScale); + void addRoom(int64_t seed, int xOffs, int zOffs, + std::vector& blocks, double xRoom, double yRoom, + double zRoom); + void addTunnel(int64_t seed, int xOffs, int zOffs, + std::vector& blocks, double xCave, double yCave, + double zCave, float thickness, float yRot, float xRot, + int step, int dist, double yScale); virtual void addFeature(Level* level, int x, int z, int xOffs, int zOffs, std::vector& blocks); }; diff --git a/targets/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp b/targets/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp index c349c3377..104c3c486 100644 --- a/targets/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp +++ b/targets/minecraft/world/level/levelgen/LargeHellCaveFeature.cpp @@ -8,8 +8,8 @@ #include "minecraft/world/level/tile/Tile.h" void LargeHellCaveFeature::addRoom(int64_t seed, int xOffs, int zOffs, - std::vector& blocks, double xRoom, double yRoom, - double zRoom) { + std::vector& blocks, double xRoom, + double yRoom, double zRoom) { addTunnel(seed, xOffs, zOffs, blocks, xRoom, yRoom, zRoom, 1 + random->nextFloat() * 6, 0, 0, -1, -1, 0.5); } @@ -41,7 +41,8 @@ void LargeHellCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, bool steep = random.nextInt(6) == 0; for (; step < dist; step++) { - double rad = 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; + double rad = + 1.5 + (Mth::sin(step * std::numbers::pi / dist) * thickness) * 1; double yRad = rad * yScale; float xc = Mth::cos(xRot); @@ -67,11 +68,11 @@ void LargeHellCaveFeature::addTunnel(int64_t seed, int xOffs, int zOffs, if (!singleStep && step == splitPoint && thickness > 1) { addTunnel(random.nextLong(), xOffs, zOffs, blocks, xCave, yCave, - zCave, random.nextFloat() * 0.5f + 0.5f, yRot - std::numbers::pi / 2, - xRot / 3, step, dist, 1.0); + zCave, random.nextFloat() * 0.5f + 0.5f, + yRot - std::numbers::pi / 2, xRot / 3, step, dist, 1.0); addTunnel(random.nextLong(), xOffs, zOffs, blocks, xCave, yCave, - zCave, random.nextFloat() * 0.5f + 0.5f, yRot + std::numbers::pi / 2, - xRot / 3, step, dist, 1.0); + zCave, random.nextFloat() * 0.5f + 0.5f, + yRot + std::numbers::pi / 2, xRot / 3, step, dist, 1.0); return; } if (!singleStep && random.nextInt(4) == 0) continue; diff --git a/targets/minecraft/world/level/levelgen/LargeHellCaveFeature.h b/targets/minecraft/world/level/levelgen/LargeHellCaveFeature.h index 91e272b2e..5f6d07cb9 100644 --- a/targets/minecraft/world/level/levelgen/LargeHellCaveFeature.h +++ b/targets/minecraft/world/level/levelgen/LargeHellCaveFeature.h @@ -8,11 +8,13 @@ class LargeHellCaveFeature : public LargeFeature { protected: - void addRoom(int64_t seed, int xOffs, int zOffs, std::vector& blocks, - double xRoom, double yRoom, double zRoom); - void addTunnel(int64_t seed, int xOffs, int zOffs, std::vector& blocks, - double xCave, double yCave, double zCave, float thickness, - float yRot, float xRot, int step, int dist, double yScale); + void addRoom(int64_t seed, int xOffs, int zOffs, + std::vector& blocks, double xRoom, double yRoom, + double zRoom); + void addTunnel(int64_t seed, int xOffs, int zOffs, + std::vector& blocks, double xCave, double yCave, + double zCave, float thickness, float yRot, float xRot, + int step, int dist, double yScale); virtual void addFeature(Level* level, int x, int z, int xOffs, int zOffs, std::vector& blocks); }; diff --git a/targets/minecraft/world/level/levelgen/RandomLevelSource.cpp b/targets/minecraft/world/level/levelgen/RandomLevelSource.cpp index dcf5483cc..4c3815630 100644 --- a/targets/minecraft/world/level/levelgen/RandomLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/RandomLevelSource.cpp @@ -95,7 +95,6 @@ RandomLevelSource::~RandomLevelSource() { } delete forestNoise; - } int g_numPrepareHeightCalls = 0; @@ -238,7 +237,8 @@ float RandomLevelSource::getHeightFalloff(int xxx, int zzz, int* pEMin) { #endif -void RandomLevelSource::prepareHeights(int xOffs, int zOffs, std::vector& blocks) { +void RandomLevelSource::prepareHeights(int xOffs, int zOffs, + std::vector& blocks) { std::int64_t startTime; int xChunks = 16 / CHUNK_WIDTH; int yChunks = Level::genDepth / CHUNK_HEIGHT; @@ -248,15 +248,16 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, std::vector biomes; // 4J created locally here for thread safety, java has - // this as a class member + std::vector biomes; // 4J created locally here for thread safety, + // java has this as a class member level->getBiomeSource()->getRawBiomeBlock(biomes, xOffs * CHUNK_WIDTH - 2, zOffs * CHUNK_WIDTH - 2, xSize + 5, zSize + 5); - std::vector buffer; // 4J - used to be declared with class level scope but - // tidying up for thread safety reasons + std::vector + buffer; // 4J - used to be declared with class level scope but + // tidying up for thread safety reasons buffer = getHeights(buffer, xOffs * xChunks, 0, zOffs * xChunks, xSize, ySize, zSize, biomes); @@ -378,18 +379,18 @@ void RandomLevelSource::prepareHeights(int xOffs, int zOffs, std::vector& blocks, +void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, + std::vector& blocks, std::vector& biomes) { int waterHeight = level->seaLevel; double s = 1 / 32.0; - std::vector depthBuffer(16 * - 16); // 4J - used to be declared with class level - // scope but moved here for thread safety + std::vector depthBuffer( + 16 * 16); // 4J - used to be declared with class level + // scope but moved here for thread safety depthBuffer = perlinNoise3->getRegion(depthBuffer, xOffs * 16, zOffs * 16, 0, 16, 16, 1, s * 2, s * 2, s * 2); @@ -467,7 +468,6 @@ void RandomLevelSource::buildSurfaces(int xOffs, int zOffs, std::vector } } } - } LevelChunk* RandomLevelSource::create(int x, int z) { return getChunk(x, z); } @@ -480,8 +480,10 @@ LevelChunk* RandomLevelSource::getChunk(int xOffs, int zOffs) { int blocksSize = Level::genDepth * 16 * 16; uint8_t* tileData = (uint8_t*)malloc(blocksSize); memset(tileData, 0, blocksSize); - std::vector blocks = std::vector(tileData, tileData + blocksSize); - // std::vector blocks = std::vector(16 * level->depth * 16); + std::vector blocks = + std::vector(tileData, tileData + blocksSize); + // std::vector blocks = std::vector(16 * level->depth * + // 16); // LevelChunk *levelChunk = new LevelChunk(level, blocks, xOffs, zOffs); // // 4J - moved to below @@ -496,7 +498,6 @@ LevelChunk* RandomLevelSource::getChunk(int xOffs, int zOffs) { buildSurfaces(xOffs, zOffs, blocks, biomes); - caveFeature->apply(this, level, xOffs, zOffs, blocks); // 4J Stu Design Change - 1.8 gen goes stronghold, mineshaft, village, // canyon this changed in 1.2 to canyon, mineshaft, village, stronghold This @@ -536,9 +537,11 @@ LevelChunk* RandomLevelSource::getChunk(int xOffs, int zOffs) { // does the same. void RandomLevelSource::lightChunk(LevelChunk* lc) { lc->recalcHeightmap(); } -std::vector RandomLevelSource::getHeights(std::vector& buffer, int x, int y, - int z, int xSize, int ySize, - int zSize, std::vector& biomes) { +std::vector RandomLevelSource::getHeights(std::vector& buffer, + int x, int y, int z, + int xSize, int ySize, + int zSize, + std::vector& biomes) { if (buffer.empty()) { buffer = std::vector(xSize * ySize * zSize); } @@ -661,7 +664,6 @@ std::vector RandomLevelSource::getHeights(std::vector& buffer, i } } - return buffer; } @@ -757,15 +759,14 @@ void RandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { bool hasVillage = false; - if (generateStructures) { + if (generateStructures) { mineShaftFeature->postProcess(level, pprandom, xt, zt); hasVillage = villageFeature->postProcess(level, pprandom, xt, zt); strongholdFeature->postProcess(level, pprandom, xt, zt); scatteredFeature->postProcess(level, random, xt, zt); } - - if (biome != Biome::desert && biome != Biome::desertHills) { + if (biome != Biome::desert && biome != Biome::desertHills) { if (!hasVillage && pprandom->nextInt(4) == 0) { int x = xo + pprandom->nextInt(16) + 8; int y = pprandom->nextInt(Level::genDepth); @@ -775,9 +776,8 @@ void RandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { calmWater.place(level, pprandom, x, y, z); } } - - if (!hasVillage && pprandom->nextInt(8) == 0) { + if (!hasVillage && pprandom->nextInt(8) == 0) { int x = xo + pprandom->nextInt(16) + 8; int y = pprandom->nextInt(pprandom->nextInt(Level::genDepth - 8) + 8); int z = zo + pprandom->nextInt(16) + 8; @@ -786,28 +786,23 @@ void RandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { calmLava.place(level, pprandom, x, y, z); } } - - for (int i = 0; i < 8; i++) { + for (int i = 0; i < 8; i++) { int x = xo + pprandom->nextInt(16) + 8; int y = pprandom->nextInt(Level::genDepth); int z = zo + pprandom->nextInt(16) + 8; MonsterRoomFeature mrf; mrf.place(level, pprandom, x, y, z); } - - biome->decorate(level, pprandom, xo, zo); - + biome->decorate(level, pprandom, xo, zo); - app.processSchematics(parent->getChunk(xt, zt)); - + app.processSchematics(parent->getChunk(xt, zt)); - MobSpawner::postProcessSpawnMobs(level, biome, xo + 8, zo + 8, 16, 16, + MobSpawner::postProcessSpawnMobs(level, biome, xo + 8, zo + 8, 16, 16, pprandom); - - // 4J - brought forward from 1.2.3 to get snow back in taiga biomes + // 4J - brought forward from 1.2.3 to get snow back in taiga biomes xo += 8; zo += 8; for (int x = 0; x < 16; x++) { @@ -824,7 +819,6 @@ void RandomLevelSource::postProcess(ChunkSource* parent, int xt, int zt) { } } } - HeavyTile::instaFall = false; } diff --git a/targets/minecraft/world/level/levelgen/RandomLevelSource.h b/targets/minecraft/world/level/levelgen/RandomLevelSource.h index fb358ac15..14e1c0430 100644 --- a/targets/minecraft/world/level/levelgen/RandomLevelSource.h +++ b/targets/minecraft/world/level/levelgen/RandomLevelSource.h @@ -86,8 +86,9 @@ public: virtual void lightChunk(LevelChunk* lc); // 4J added private: - std::vector getHeights(std::vector& buffer, int x, int y, int z, int xSize, - int ySize, int zSize, std::vector& biomes); + std::vector getHeights(std::vector& buffer, int x, int y, + int z, int xSize, int ySize, int zSize, + std::vector& biomes); public: virtual bool hasChunk(int x, int y); diff --git a/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp b/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp index 8826f7e8e..da6a860dc 100644 --- a/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp +++ b/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.cpp @@ -43,8 +43,9 @@ TheEndLevelRandomLevelSource::~TheEndLevelRandomLevelSource() { void TheEndLevelRandomLevelSource::prepareHeights(int xOffs, int zOffs, std::vector& blocks, std::vector& biomes) { - std::vector buffer; // 4J - used to be declared with class level scope but - // tidying up for thread safety reasons + std::vector + buffer; // 4J - used to be declared with class level scope but + // tidying up for thread safety reasons int xChunks = 16 / CHUNK_WIDTH; @@ -181,8 +182,10 @@ LevelChunk* TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs) { unsigned int blocksSize = Level::genDepth * 16 * 16; uint8_t* tileData = (uint8_t*)malloc(blocksSize); memset(tileData, 0, blocksSize); - std::vector blocks = std::vector(tileData, tileData + blocksSize); - // std::vector blocks = std::vector(16 * level->depth * 16); + std::vector blocks = + std::vector(tileData, tileData + blocksSize); + // std::vector blocks = std::vector(16 * level->depth * + // 16); // LevelChunk *levelChunk = new LevelChunk(level, blocks, xOffs, zOffs); // // 4J moved below @@ -207,9 +210,9 @@ LevelChunk* TheEndLevelRandomLevelSource::getChunk(int xOffs, int zOffs) { return levelChunk; } -std::vector TheEndLevelRandomLevelSource::getHeights(std::vector& buffer, int x, - int y, int z, int xSize, - int ySize, int zSize) { +std::vector TheEndLevelRandomLevelSource::getHeights( + std::vector& buffer, int x, int y, int z, int xSize, int ySize, + int zSize) { if (buffer.empty()) { buffer = std::vector(xSize * ySize * zSize); } @@ -298,7 +301,6 @@ std::vector TheEndLevelRandomLevelSource::getHeights(std::vector } } - return buffer; } diff --git a/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.h b/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.h index 770eda279..ffdcac9eb 100644 --- a/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.h +++ b/targets/minecraft/world/level/levelgen/TheEndLevelRandomLevelSource.h @@ -53,8 +53,8 @@ public: virtual LevelChunk* getChunk(int xOffs, int zOffs); private: - std::vector getHeights(std::vector& buffer, int x, int y, int z, int xSize, - int ySize, int zSize); + std::vector getHeights(std::vector& buffer, int x, int y, + int z, int xSize, int ySize, int zSize); public: virtual bool hasChunk(int x, int y); diff --git a/targets/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp b/targets/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp index f0be6d7e1..97c514ef6 100644 --- a/targets/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/BasicTreeFeature.cpp @@ -141,7 +141,7 @@ void BasicTree::prepare() { void BasicTree::crossection(int x, int y, int z, float radius, uint8_t direction, int material) { - // Create a circular cross section. + // Create a circular cross section. // // Used to nearly everything in the foliage, branches, and trunk. // This is a good target for performance optimization. @@ -171,22 +171,21 @@ void BasicTree::crossection(int x, int y, int z, float radius, continue; } position[secidx2] = center[secidx2] + offset2; - thismat = thisLevel->getTile(position[0], position[1], position[2]); - + thismat = thisLevel->getTile(position[0], position[1], position[2]); + if (!((thismat == 0) || (thismat == Tile::leaves_Id))) { // If the material of the checked block is anything other than // air or foliage, skip this tile. offset2++; continue; } - placeBlock(thisLevel, position[0], position[1], position[2], + placeBlock(thisLevel, position[0], position[1], position[2], material, 0); - + offset2++; } offset1++; } - } float BasicTree::treeShape(int y) { @@ -227,7 +226,7 @@ float BasicTree::foliageShape(int y) { } void BasicTree::foliageCluster(int x, int y, int z) { - // Generate a cluster of foliage, with the base at x, y, z. + // Generate a cluster of foliage, with the base at x, y, z. // The shape of the cluster is derived from foliageShape // crossection is called to make each level. int topy = y + foliageHeight; @@ -240,7 +239,6 @@ void BasicTree::foliageCluster(int x, int y, int z) { crossection(x, cury, z, radius, (uint8_t)1, Tile::leaves_Id); cury--; } - } void BasicTree::limb(int* start, int* end, int material) { @@ -530,21 +528,21 @@ bool BasicTree::place(Level* level, Random* random, int x, int y, int z) { // System.out.println("Tree location failed"); return false; } - // System.out.println("The height is"); + // System.out.println("The height is"); // System.out.println(height); // System.out.println("Trunk Height check done"); - prepare(); - + prepare(); + // System.out.println("Prepare done"); - makeFoliage(); - + makeFoliage(); + // System.out.println("Foliage done"); - makeTrunk(); - + makeTrunk(); + // System.out.println("Trunk done"); - makeBranches(); - + makeBranches(); + // System.out.println("Branches done"); - + return true; } \ No newline at end of file diff --git a/targets/minecraft/world/level/levelgen/feature/BonusChestFeature.cpp b/targets/minecraft/world/level/levelgen/feature/BonusChestFeature.cpp index a02032429..cb99c75d6 100644 --- a/targets/minecraft/world/level/levelgen/feature/BonusChestFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/BonusChestFeature.cpp @@ -7,8 +7,8 @@ #include "minecraft/world/level/tile/Tile.h" #include "minecraft/world/level/tile/entity/ChestTileEntity.h" -BonusChestFeature::BonusChestFeature(std::vector& treasureList, - int numRolls) +BonusChestFeature::BonusChestFeature( + std::vector& treasureList, int numRolls) : treasureList(treasureList), numRolls(numRolls) {} // 4J - original virtual method diff --git a/targets/minecraft/world/level/levelgen/feature/BonusChestFeature.h b/targets/minecraft/world/level/levelgen/feature/BonusChestFeature.h index 624fc7a7f..55e38bbe9 100644 --- a/targets/minecraft/world/level/levelgen/feature/BonusChestFeature.h +++ b/targets/minecraft/world/level/levelgen/feature/BonusChestFeature.h @@ -14,7 +14,8 @@ private: const int numRolls; public: - BonusChestFeature(std::vector& treasureList, int numRolls); + BonusChestFeature(std::vector& treasureList, + int numRolls); virtual bool place(Level* level, Random* random, int x, int y, int z); bool place(Level* level, Random* random, int x, int y, int z, diff --git a/targets/minecraft/world/level/levelgen/feature/CaveFeature.cpp b/targets/minecraft/world/level/levelgen/feature/CaveFeature.cpp index e29f29603..01ef40118 100644 --- a/targets/minecraft/world/level/levelgen/feature/CaveFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/CaveFeature.cpp @@ -37,8 +37,10 @@ bool CaveFeature::place(Level* level, Random* random, int x, int y, int z) { double zz = z0 + (z1 - z0) * d / 16; double ss = random->nextDouble(); - double r = (Mth::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; - double hr = (Mth::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; + double r = + (Mth::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; + double hr = + (Mth::sin(d / 16.0f * std::numbers::pi) * radius + 1) * ss + 1; // 4J Stu Added to stop cave features generating areas previously place // by game rule generation diff --git a/targets/minecraft/world/level/levelgen/feature/GroundBushFeature.cpp b/targets/minecraft/world/level/levelgen/feature/GroundBushFeature.cpp index 6f04bd26e..e5946715a 100644 --- a/targets/minecraft/world/level/levelgen/feature/GroundBushFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/GroundBushFeature.cpp @@ -15,7 +15,7 @@ GroundBushFeature::GroundBushFeature(int trunkType, int leafType) { bool GroundBushFeature::place(Level* level, Random* random, int x, int y, int z) { - int t = 0; + int t = 0; while (((t = level->getTile(x, y, z)) == 0 || t == Tile::leaves_Id) && y > 0) y--; @@ -42,6 +42,6 @@ bool GroundBushFeature::place(Level* level, Random* random, int x, int y, } } } - + return true; } \ No newline at end of file diff --git a/targets/minecraft/world/level/levelgen/feature/HouseFeature.cpp b/targets/minecraft/world/level/levelgen/feature/HouseFeature.cpp index 5aa3c273b..f31647411 100644 --- a/targets/minecraft/world/level/levelgen/feature/HouseFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/HouseFeature.cpp @@ -168,8 +168,7 @@ bool HouseFeature::place(Level* level, Random* random, int x, int y, int z) { } } - std::shared_ptr(pz) = - std::make_shared(level); + std::shared_ptr(pz) = std::make_shared(level); pz->moveTo(x0 + w / 2.0 + 0.5, y0 + 0.5, z0 + d / 2.0 + 0.5, 0, 0); level->addEntity(pz); diff --git a/targets/minecraft/world/level/levelgen/feature/MonsterRoomFeature.cpp b/targets/minecraft/world/level/levelgen/feature/MonsterRoomFeature.cpp index 8a0ab8b81..5adac555b 100644 --- a/targets/minecraft/world/level/levelgen/feature/MonsterRoomFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/MonsterRoomFeature.cpp @@ -102,11 +102,13 @@ bool MonsterRoomFeature::place(Level* level, Random* random, int x, int y, level->setTileAndData(xc, yc, zc, Tile::chest_Id, 0, Tile::UPDATE_CLIENTS); - std::vector wrapperArray(monsterRoomTreasure, - monsterRoomTreasure + TREASURE_ITEMS_COUNT); - std::vector treasure = WeighedTreasure::addToTreasure( - wrapperArray, - Item::enchantedBook->createForRandomTreasure(random)); + std::vector wrapperArray( + monsterRoomTreasure, + monsterRoomTreasure + TREASURE_ITEMS_COUNT); + std::vector treasure = + WeighedTreasure::addToTreasure( + wrapperArray, + Item::enchantedBook->createForRandomTreasure(random)); std::shared_ptr chest = std::dynamic_pointer_cast( level->getTileEntity(xc, yc, zc)); diff --git a/targets/minecraft/world/level/levelgen/feature/OreFeature.cpp b/targets/minecraft/world/level/levelgen/feature/OreFeature.cpp index fa5e3d1a5..fad0f73d9 100644 --- a/targets/minecraft/world/level/levelgen/feature/OreFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/OreFeature.cpp @@ -26,7 +26,7 @@ OreFeature::OreFeature(int tile, int count, int targetTile) { } bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { - float dir = random->nextFloat() * std::numbers::pi; + float dir = random->nextFloat() * std::numbers::pi; double x0 = x + 8 + Mth::sin(dir) * count / 8; double x1 = x + 8 - Mth::sin(dir) * count / 8; @@ -147,6 +147,5 @@ bool OreFeature::place(Level* level, Random* random, int x, int y, int z) { } } - return true; } \ No newline at end of file diff --git a/targets/minecraft/world/level/levelgen/feature/TreeFeature.cpp b/targets/minecraft/world/level/levelgen/feature/TreeFeature.cpp index 3c9a15f63..322b42635 100644 --- a/targets/minecraft/world/level/levelgen/feature/TreeFeature.cpp +++ b/targets/minecraft/world/level/levelgen/feature/TreeFeature.cpp @@ -37,11 +37,11 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z) { // 4J Stu Added to stop tree features generating areas previously place by // game rule generation if (app.getLevelGenerationOptions() != nullptr) { - LevelGenerationOptions* levelGenOptions = + LevelGenerationOptions* levelGenOptions = app.getLevelGenerationOptions(); bool intersects = levelGenOptions->checkIntersects( x - 2, y - 1, z - 2, x + 2, y + treeHeight, z + 2); - + if (intersects) { // app.DebugPrintf("Skipping reeds feature generation as it overlaps // a game rule structure\n"); @@ -77,7 +77,7 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z) { placeBlock(level, x, y - 1, z, Tile::dirt_Id, 0); - int grassHeight = 3; + int grassHeight = 3; int extraWidth = 0; // 4J Stu - Generate leaves from the top down to stop having to recalc // heightmaps @@ -97,8 +97,8 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z) { } } } - - for (int hh = 0; hh < treeHeight; hh++) { + + for (int hh = 0; hh < treeHeight; hh++) { int t = level->getTile(x, y + hh, z); if (t == 0 || t == Tile::leaves_Id) { placeBlock(level, x, y + hh, z, Tile::treeTrunk_Id, trunkType); @@ -126,9 +126,9 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z) { } } } - + if (addJungleFeatures) { - for (int yy = y - 3 + treeHeight; yy <= y + treeHeight; yy++) { + for (int yy = y - 3 + treeHeight; yy <= y + treeHeight; yy++) { int yo = yy - (y + treeHeight); int offs = 2 - yo / 2; for (int xx = x - offs; xx <= x + offs; xx++) { @@ -156,10 +156,10 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z) { } } } - + // also chance for cocoa plants around stem if (random->nextInt(5) == 0 && treeHeight > 5) { - for (int rows = 0; rows < 2; rows++) { + for (int rows = 0; rows < 2; rows++) { for (int dir = 0; dir < 4; dir++) { if (random->nextInt(4 - rows) == 0) { int age = random->nextInt(3); @@ -173,7 +173,6 @@ bool TreeFeature::place(Level* level, Random* random, int x, int y, int z) { } } } - } } diff --git a/targets/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp b/targets/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp index 79c4696fe..f7855b410 100644 --- a/targets/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp +++ b/targets/minecraft/world/level/levelgen/structure/BlockGenMethods.cpp @@ -5,9 +5,10 @@ #include "minecraft/util/Mth.h" #include "minecraft/world/level/Level.h" -void BlockGenMethods::generateBox(Level* level, std::vector& blocks, int sx, - int sy, int sz, int ex, int ey, int ez, - std::uint8_t edge, std::uint8_t filling) { +void BlockGenMethods::generateBox(Level* level, std::vector& blocks, + int sx, int sy, int sz, int ex, int ey, + int ez, std::uint8_t edge, + std::uint8_t filling) { sx = Mth::clamp(sx, 0, 15); sy = Mth::clamp(sy, 0, Level::genDepthMinusOne); sz = Mth::clamp(sz, 0, 15); @@ -31,8 +32,8 @@ void BlockGenMethods::generateBox(Level* level, std::vector& blocks, in } } -void BlockGenMethods::generateFrame(Level* level, std::vector& blocks, int sx, - int sy, int ex, int ey, int flatZ, +void BlockGenMethods::generateFrame(Level* level, std::vector& blocks, + int sx, int sy, int ex, int ey, int flatZ, int direction, std::uint8_t edge, std::uint8_t filling) { sx = Mth::clamp(sx, 0, 15); @@ -86,11 +87,9 @@ void BlockGenMethods::generateFrame(Level* level, std::vector& blocks, } } -void BlockGenMethods::generateDirectionLine(Level* level, std::vector& blocks, - int sx, int sy, int sz, int ex, - int ey, int ez, int startDirection, - int endDirection, - std::uint8_t block) { +void BlockGenMethods::generateDirectionLine( + Level* level, std::vector& blocks, int sx, int sy, int sz, int ex, + int ey, int ez, int startDirection, int endDirection, std::uint8_t block) { sx = Mth::clamp(sx, 0, 15); sy = Mth::clamp(sy, 0, Level::genDepthMinusOne); sz = Mth::clamp(sz, 0, 15); @@ -184,8 +183,8 @@ void BlockGenMethods::generateDirectionLine(Level* level, std::vector& } } -void BlockGenMethods::generateLine(Level* level, std::vector& blocks, int sx, - int sy, int sz, int ex, int ey, int ez, - std::uint8_t block) { +void BlockGenMethods::generateLine(Level* level, std::vector& blocks, + int sx, int sy, int sz, int ex, int ey, + int ez, std::uint8_t block) { generateDirectionLine(level, blocks, sx, sy, sz, ex, ey, ez, 0, 0, block); } diff --git a/targets/minecraft/world/level/levelgen/structure/BlockGenMethods.h b/targets/minecraft/world/level/levelgen/structure/BlockGenMethods.h index 1e91bc847..87dd7cc66 100644 --- a/targets/minecraft/world/level/levelgen/structure/BlockGenMethods.h +++ b/targets/minecraft/world/level/levelgen/structure/BlockGenMethods.h @@ -2,22 +2,23 @@ #include #include - class Level; class BlockGenMethods { public: - static void generateBox(Level* level, std::vector& blocks, int sx, int sy, - int sz, int ex, int ey, int ez, std::uint8_t edge, - std::uint8_t filling); - static void generateFrame(Level* level, std::vector& blocks, int sx, int sy, - int ex, int ey, int flatZ, int direction, - std::uint8_t edge, std::uint8_t filling); - static void generateDirectionLine(Level* level, std::vector& blocks, int sx, + static void generateBox(Level* level, std::vector& blocks, int sx, + int sy, int sz, int ex, int ey, int ez, + std::uint8_t edge, std::uint8_t filling); + static void generateFrame(Level* level, std::vector& blocks, + int sx, int sy, int ex, int ey, int flatZ, + int direction, std::uint8_t edge, + std::uint8_t filling); + static void generateDirectionLine(Level* level, + std::vector& blocks, int sx, int sy, int sz, int ex, int ey, int ez, int startDirection, int endDirection, std::uint8_t block); - static void generateLine(Level* level, std::vector& blocks, int sx, int sy, - int sz, int ex, int ey, int ez, + static void generateLine(Level* level, std::vector& blocks, int sx, + int sy, int sz, int ex, int ey, int ez, std::uint8_t block); }; diff --git a/targets/minecraft/world/level/levelgen/structure/MineShaftPieces.cpp b/targets/minecraft/world/level/levelgen/structure/MineShaftPieces.cpp index 94e9cc336..ad1c79fb6 100644 --- a/targets/minecraft/world/level/levelgen/structure/MineShaftPieces.cpp +++ b/targets/minecraft/world/level/levelgen/structure/MineShaftPieces.cpp @@ -490,8 +490,8 @@ bool MineShaftPieces::MineShaftCorridor::createChest( : RailTile::DIR_FLAT_Z), Tile::UPDATE_CLIENTS); std::shared_ptr chest = - std::make_shared( - level, worldX + 0.5f, worldY + 0.5f, worldZ + 0.5f); + std::make_shared(level, worldX + 0.5f, + worldY + 0.5f, worldZ + 0.5f); WeighedTreasure::addChestItems(random, treasure, chest, numRolls); level->addEntity(chest); return true; diff --git a/targets/minecraft/world/level/levelgen/structure/MineShaftPieces.h b/targets/minecraft/world/level/levelgen/structure/MineShaftPieces.h index e462c0199..de4c3957d 100644 --- a/targets/minecraft/world/level/levelgen/structure/MineShaftPieces.h +++ b/targets/minecraft/world/level/levelgen/structure/MineShaftPieces.h @@ -102,7 +102,8 @@ public: protected: virtual bool createChest(Level* level, BoundingBox* chunkBB, Random* random, int x, int y, int z, - const std::vector& treasure, int numRolls); + const std::vector& treasure, + int numRolls); public: virtual bool postProcess(Level* level, Random* random, diff --git a/targets/minecraft/world/level/levelgen/structure/NetherBridgePieces.cpp b/targets/minecraft/world/level/levelgen/structure/NetherBridgePieces.cpp index a4a45a74e..6bc3afed0 100644 --- a/targets/minecraft/world/level/levelgen/structure/NetherBridgePieces.cpp +++ b/targets/minecraft/world/level/levelgen/structure/NetherBridgePieces.cpp @@ -1659,10 +1659,12 @@ bool NetherBridgePieces::CastleSmallCorridorRightTurnPiece::postProcess( int x = getWorldX(1, 3), z = getWorldZ(1, 3); if (chunkBB->isInside(x, y, z)) { isNeedingChest = false; - createChest(level, chunkBB, random, 1, 2, 3, - std::vector(fortressTreasureItems, fortressTreasureItems + - FORTRESS_TREASURE_ITEMS_COUNT), - 2 + random->nextInt(4)); + createChest( + level, chunkBB, random, 1, 2, 3, + std::vector( + fortressTreasureItems, + fortressTreasureItems + FORTRESS_TREASURE_ITEMS_COUNT), + 2 + random->nextInt(4)); } } @@ -1767,10 +1769,12 @@ bool NetherBridgePieces::CastleSmallCorridorLeftTurnPiece::postProcess( int x = getWorldX(3, 3), z = getWorldZ(3, 3); if (chunkBB->isInside(x, y, z)) { isNeedingChest = false; - createChest(level, chunkBB, random, 3, 2, 3, - std::vector(fortressTreasureItems, fortressTreasureItems + - FORTRESS_TREASURE_ITEMS_COUNT), - 2 + random->nextInt(4)); + createChest( + level, chunkBB, random, 3, 2, 3, + std::vector( + fortressTreasureItems, + fortressTreasureItems + FORTRESS_TREASURE_ITEMS_COUNT), + 2 + random->nextInt(4)); } } diff --git a/targets/minecraft/world/level/levelgen/structure/ScatteredFeaturePieces.cpp b/targets/minecraft/world/level/levelgen/structure/ScatteredFeaturePieces.cpp index 88f0d5693..c6118dec7 100644 --- a/targets/minecraft/world/level/levelgen/structure/ScatteredFeaturePieces.cpp +++ b/targets/minecraft/world/level/levelgen/structure/ScatteredFeaturePieces.cpp @@ -470,7 +470,13 @@ bool ScatteredFeaturePieces::DesertPyramidPiece::postProcess( int zo = Direction::STEP_Z[i] * 2; hasPlacedChest[i] = createChest( level, chunkBB, random, 10 + xo, -11, 10 + zo, - [&]() { auto items = std::vector(treasureItems, treasureItems + TREASURE_ITEMS_COUNT); return WeighedTreasure::addToTreasure(items, Item::enchantedBook->createForRandomTreasure(random)); }(), + [&]() { + auto items = std::vector( + treasureItems, treasureItems + TREASURE_ITEMS_COUNT); + return WeighedTreasure::addToTreasure( + items, + Item::enchantedBook->createForRandomTreasure(random)); + }(), 2 + random->nextInt(5)); } } @@ -721,7 +727,9 @@ bool ScatteredFeaturePieces::JunglePyramidPiece::postProcess( if (!placedTrap1) { placedTrap1 = createDispenser( level, chunkBB, random, 3, -2, 1, Facing::NORTH, - std::vector(dispenserItems, dispenserItems + DISPENSER_ITEMS_COUNT), 2); + std::vector( + dispenserItems, dispenserItems + DISPENSER_ITEMS_COUNT), + 2); } placeBlock(level, Tile::vine_Id, 0xf, 3, -2, 2, chunkBB); @@ -748,14 +756,22 @@ bool ScatteredFeaturePieces::JunglePyramidPiece::postProcess( if (!placedTrap2) { placedTrap2 = createDispenser( level, chunkBB, random, 9, -2, 3, Facing::WEST, - std::vector(dispenserItems, dispenserItems + DISPENSER_ITEMS_COUNT), 2); + std::vector( + dispenserItems, dispenserItems + DISPENSER_ITEMS_COUNT), + 2); } placeBlock(level, Tile::vine_Id, 0xf, 8, -1, 3, chunkBB); placeBlock(level, Tile::vine_Id, 0xf, 8, -2, 3, chunkBB); if (!placedMainChest) { placedMainChest = createChest( level, chunkBB, random, 8, -3, 3, - [&]() { auto items = std::vector(treasureItems, treasureItems + TREASURE_ITEMS_COUNT); return WeighedTreasure::addToTreasure(items, Item::enchantedBook->createForRandomTreasure(random)); }(), + [&]() { + auto items = std::vector( + treasureItems, treasureItems + TREASURE_ITEMS_COUNT); + return WeighedTreasure::addToTreasure( + items, + Item::enchantedBook->createForRandomTreasure(random)); + }(), 2 + random->nextInt(5)); } placeBlock(level, Tile::mossyCobblestone_Id, 0, 9, -3, 2, chunkBB); @@ -811,7 +827,13 @@ bool ScatteredFeaturePieces::JunglePyramidPiece::postProcess( if (!placedHiddenChest) { placedHiddenChest = createChest( level, chunkBB, random, 9, -3, 10, - [&]() { auto items = std::vector(treasureItems, treasureItems + TREASURE_ITEMS_COUNT); return WeighedTreasure::addToTreasure(items, Item::enchantedBook->createForRandomTreasure(random)); }(), + [&]() { + auto items = std::vector( + treasureItems, treasureItems + TREASURE_ITEMS_COUNT); + return WeighedTreasure::addToTreasure( + items, + Item::enchantedBook->createForRandomTreasure(random)); + }(), 2 + random->nextInt(5)); } @@ -944,8 +966,7 @@ bool ScatteredFeaturePieces::SwamplandHut::postProcess(Level* level, if (chunkBB->isInside(wx, wy, wz)) { spawnedWitch = true; - std::shared_ptr witch = - std::make_shared(level); + std::shared_ptr witch = std::make_shared(level); witch->moveTo(wx + .5, wy, wz + .5, 0, 0); witch->finalizeMobSpawn(nullptr); level->addEntity(witch); diff --git a/targets/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp b/targets/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp index bc1534a24..4d8cc0c0d 100644 --- a/targets/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp +++ b/targets/minecraft/world/level/levelgen/structure/StrongholdFeature.cpp @@ -183,7 +183,8 @@ bool StrongholdFeature::isFeatureChunk(int x, int z, bool bIsSuperflat) { // 4J Stu - Randomise the angles for retries as well #ifdef _LARGE_WORLDS - angle = random.nextDouble() * std::numbers::pi * 2.0 * circle / (double)spread; + angle = random.nextDouble() * std::numbers::pi * 2.0 * circle / + (double)spread; #endif } while (!hasFoundValidPos && findAttempts < MAX_STRONGHOLD_ATTEMPTS); diff --git a/targets/minecraft/world/level/levelgen/structure/StrongholdPieces.cpp b/targets/minecraft/world/level/levelgen/structure/StrongholdPieces.cpp index 8a1c2a8a6..b889b03c4 100644 --- a/targets/minecraft/world/level/levelgen/structure/StrongholdPieces.cpp +++ b/targets/minecraft/world/level/levelgen/structure/StrongholdPieces.cpp @@ -925,7 +925,13 @@ bool StrongholdPieces::ChestCorridor::postProcess(Level* level, Random* random, hasPlacedChest = true; createChest( level, chunkBB, random, 3, 2, 3, - [&]() { auto items = std::vector(treasureItems, treasureItems + TREASURE_ITEMS_COUNT); return WeighedTreasure::addToTreasure(items, Item::enchantedBook->createForRandomTreasure(random)); }(), + [&]() { + auto items = std::vector( + treasureItems, treasureItems + TREASURE_ITEMS_COUNT); + return WeighedTreasure::addToTreasure( + items, + Item::enchantedBook->createForRandomTreasure(random)); + }(), 2 + random->nextInt(2)); } } @@ -1278,7 +1284,14 @@ bool StrongholdPieces::RoomCrossing::postProcess(Level* level, Random* random, createChest( level, chunkBB, random, 3, 4, 8, - [&]() { auto items = std::vector(smallTreasureItems, smallTreasureItems + SMALL_TREASURE_ITEMS_COUNT); return WeighedTreasure::addToTreasure(items, Item::enchantedBook->createForRandomTreasure(random)); }(), + [&]() { + auto items = std::vector( + smallTreasureItems, + smallTreasureItems + SMALL_TREASURE_ITEMS_COUNT); + return WeighedTreasure::addToTreasure( + items, + Item::enchantedBook->createForRandomTreasure(random)); + }(), 1 + random->nextInt(4)); // System.out.println("Created chest at " + getWorldX(3, 8) + // "," + getWorldY(4) + "," + getWorldZ(3, 8)); @@ -1576,13 +1589,27 @@ bool StrongholdPieces::Library::postProcess(Level* level, Random* random, // place chests createChest( level, chunkBB, random, 3, 3, 5, - [&]() { auto items = std::vector(libraryTreasureItems, libraryTreasureItems + LIBRARY_TREASURE_ITEMS_COUNT); return WeighedTreasure::addToTreasure(items, Item::enchantedBook->createForRandomTreasure(random, 1, 5, 2)); }(), + [&]() { + auto items = std::vector( + libraryTreasureItems, + libraryTreasureItems + LIBRARY_TREASURE_ITEMS_COUNT); + return WeighedTreasure::addToTreasure( + items, + Item::enchantedBook->createForRandomTreasure(random, 1, 5, 2)); + }(), 1 + random->nextInt(4)); if (isTall) { placeBlock(level, 0, 0, width - 2, tallHeight - 2, 1, chunkBB); createChest( level, chunkBB, random, width - 2, tallHeight - 3, 1, - [&]() { auto items = std::vector(libraryTreasureItems, libraryTreasureItems + LIBRARY_TREASURE_ITEMS_COUNT); return WeighedTreasure::addToTreasure(items, Item::enchantedBook->createForRandomTreasure(random, 1, 5, 2)); }(), + [&]() { + auto items = std::vector( + libraryTreasureItems, + libraryTreasureItems + LIBRARY_TREASURE_ITEMS_COUNT); + return WeighedTreasure::addToTreasure( + items, Item::enchantedBook->createForRandomTreasure( + random, 1, 5, 2)); + }(), 1 + random->nextInt(4)); } diff --git a/targets/minecraft/world/level/levelgen/structure/StructurePiece.cpp b/targets/minecraft/world/level/levelgen/structure/StructurePiece.cpp index 09faf08c0..7fb34792c 100644 --- a/targets/minecraft/world/level/levelgen/structure/StructurePiece.cpp +++ b/targets/minecraft/world/level/levelgen/structure/StructurePiece.cpp @@ -662,7 +662,8 @@ void StructurePiece::fillColumnDown(Level* level, int tile, int tileData, int x, bool StructurePiece::createChest(Level* level, BoundingBox* chunkBB, Random* random, int x, int y, int z, - const std::vector& treasure, int numRolls) { + const std::vector& treasure, + int numRolls) { int worldX = getWorldX(x, z); int worldY = getWorldY(y); int worldZ = getWorldZ(x, z); @@ -685,7 +686,8 @@ bool StructurePiece::createChest(Level* level, BoundingBox* chunkBB, bool StructurePiece::createDispenser(Level* level, BoundingBox* chunkBB, Random* random, int x, int y, int z, - int facing, const std::vector& items, + int facing, + const std::vector& items, int numRolls) { int worldX = getWorldX(x, z); int worldY = getWorldY(y); diff --git a/targets/minecraft/world/level/levelgen/structure/StructurePiece.h b/targets/minecraft/world/level/levelgen/structure/StructurePiece.h index 2d6a2ec52..18dc04bf8 100644 --- a/targets/minecraft/world/level/levelgen/structure/StructurePiece.h +++ b/targets/minecraft/world/level/levelgen/structure/StructurePiece.h @@ -165,11 +165,13 @@ public: virtual void fillColumnDown(Level* level, int tile, int tileData, int x, int startY, int z, BoundingBox* chunkBB); virtual bool createChest(Level* level, BoundingBox* chunkBB, Random* random, - int x, int y, int z, const std::vector& treasure, + int x, int y, int z, + const std::vector& treasure, int numRolls); virtual bool createDispenser(Level* level, BoundingBox* chunkBB, Random* random, int x, int y, int z, - int facing, const std::vector& items, + int facing, + const std::vector& items, int numRolls); protected: diff --git a/targets/minecraft/world/level/levelgen/structure/VillagePieces.cpp b/targets/minecraft/world/level/levelgen/structure/VillagePieces.cpp index 649e4173a..6c90ca96d 100644 --- a/targets/minecraft/world/level/levelgen/structure/VillagePieces.cpp +++ b/targets/minecraft/world/level/levelgen/structure/VillagePieces.cpp @@ -71,33 +71,32 @@ std::list* VillagePieces::createPieceSet( Random* random, int villageSize) { std::list* newPieces = new std::list; - newPieces->push_back(new PieceWeight( - VillagePieces::EPieceClass_SimpleHouse, 4, - random->nextInt(2 + villageSize, 4 + villageSize * 2))); - newPieces->push_back(new PieceWeight( - VillagePieces::EPieceClass_SmallTemple, 20, - random->nextInt(0 + villageSize, 1 + villageSize))); - newPieces->push_back(new PieceWeight( - VillagePieces::EPieceClass_BookHouse, 20, - random->nextInt(0 + villageSize, 2 + villageSize))); - newPieces->push_back(new PieceWeight( - VillagePieces::EPieceClass_SmallHut, 3, - random->nextInt(2 + villageSize, 5 + villageSize * 3))); - newPieces->push_back(new PieceWeight( - VillagePieces::EPieceClass_PigHouse, 15, - random->nextInt(0 + villageSize, 2 + villageSize))); - newPieces->push_back(new PieceWeight( - VillagePieces::EPieceClass_DoubleFarmland, 3, - random->nextInt(1 + villageSize, 4 + villageSize))); - newPieces->push_back(new PieceWeight( - VillagePieces::EPieceClass_Farmland, 3, - random->nextInt(2 + villageSize, 4 + villageSize * 2))); newPieces->push_back( - new PieceWeight(VillagePieces::EPieceClass_Smithy, 15, - random->nextInt(0, 1 + villageSize))); - newPieces->push_back(new PieceWeight( - VillagePieces::EPieceClass_TwoRoomHouse, 8, - random->nextInt(0 + villageSize, 3 + villageSize * 2))); + new PieceWeight(VillagePieces::EPieceClass_SimpleHouse, 4, + random->nextInt(2 + villageSize, 4 + villageSize * 2))); + newPieces->push_back( + new PieceWeight(VillagePieces::EPieceClass_SmallTemple, 20, + random->nextInt(0 + villageSize, 1 + villageSize))); + newPieces->push_back( + new PieceWeight(VillagePieces::EPieceClass_BookHouse, 20, + random->nextInt(0 + villageSize, 2 + villageSize))); + newPieces->push_back( + new PieceWeight(VillagePieces::EPieceClass_SmallHut, 3, + random->nextInt(2 + villageSize, 5 + villageSize * 3))); + newPieces->push_back( + new PieceWeight(VillagePieces::EPieceClass_PigHouse, 15, + random->nextInt(0 + villageSize, 2 + villageSize))); + newPieces->push_back( + new PieceWeight(VillagePieces::EPieceClass_DoubleFarmland, 3, + random->nextInt(1 + villageSize, 4 + villageSize))); + newPieces->push_back( + new PieceWeight(VillagePieces::EPieceClass_Farmland, 3, + random->nextInt(2 + villageSize, 4 + villageSize * 2))); + newPieces->push_back(new PieceWeight(VillagePieces::EPieceClass_Smithy, 15, + random->nextInt(0, 1 + villageSize))); + newPieces->push_back( + new PieceWeight(VillagePieces::EPieceClass_TwoRoomHouse, 8, + random->nextInt(0 + villageSize, 3 + villageSize * 2))); // silly way of filtering "infinite" buildings auto it = newPieces->begin(); @@ -2103,10 +2102,8 @@ bool VillagePieces::DoubleFarmland::postProcess(Level* level, Random* random, placeBlock(level, cropsB, random->nextInt(2, 7), 5, 1, d, chunkBB); placeBlock(level, cropsC, random->nextInt(2, 7), 7, 1, d, chunkBB); placeBlock(level, cropsC, random->nextInt(2, 7), 8, 1, d, chunkBB); - placeBlock(level, cropsD, random->nextInt(2, 7), 10, 1, d, - chunkBB); - placeBlock(level, cropsD, random->nextInt(2, 7), 11, 1, d, - chunkBB); + placeBlock(level, cropsD, random->nextInt(2, 7), 10, 1, d, chunkBB); + placeBlock(level, cropsD, random->nextInt(2, 7), 11, 1, d, chunkBB); } for (int z = 0; z < depth; z++) { diff --git a/targets/minecraft/world/level/levelgen/synth/FastNoise.cpp b/targets/minecraft/world/level/levelgen/synth/FastNoise.cpp index d1d73f28c..82b3e5ef6 100644 --- a/targets/minecraft/world/level/levelgen/synth/FastNoise.cpp +++ b/targets/minecraft/world/level/levelgen/synth/FastNoise.cpp @@ -24,9 +24,10 @@ FastNoise::~FastNoise() { delete[] noiseMaps; } -std::vector FastNoise::getRegion(std::vector& buffer, double x, double y, - double z, int xSize, int ySize, int zSize, - double xScale, double yScale, double zScale) { +std::vector FastNoise::getRegion(std::vector& buffer, double x, + double y, double z, int xSize, + int ySize, int zSize, double xScale, + double yScale, double zScale) { if (buffer.empty()) buffer = std::vector(xSize * ySize * zSize); else diff --git a/targets/minecraft/world/level/levelgen/synth/FastNoise.h b/targets/minecraft/world/level/levelgen/synth/FastNoise.h index 24505c146..06d436494 100644 --- a/targets/minecraft/world/level/levelgen/synth/FastNoise.h +++ b/targets/minecraft/world/level/levelgen/synth/FastNoise.h @@ -18,7 +18,8 @@ public: void init(Random* random, int levels); ~FastNoise(); - std::vector getRegion(std::vector& buffer, double x, double y, double z, - int xSize, int ySize, int zSize, double xScale, - double yScale, double zScale); + std::vector getRegion(std::vector& buffer, double x, + double y, double z, int xSize, int ySize, + int zSize, double xScale, double yScale, + double zScale); }; \ No newline at end of file diff --git a/targets/minecraft/world/level/levelgen/synth/ImprovedNoise.cpp b/targets/minecraft/world/level/levelgen/synth/ImprovedNoise.cpp index d55617739..7e3b2ad79 100644 --- a/targets/minecraft/world/level/levelgen/synth/ImprovedNoise.cpp +++ b/targets/minecraft/world/level/levelgen/synth/ImprovedNoise.cpp @@ -106,9 +106,9 @@ double ImprovedNoise::getValue(double x, double y, double z) { return noise(x, y, z); } -void ImprovedNoise::add(std::vector& buffer, double _x, double _y, double _z, - int xSize, int ySize, int zSize, double xs, double ys, - double zs, double pow) { +void ImprovedNoise::add(std::vector& buffer, double _x, double _y, + double _z, int xSize, int ySize, int zSize, double xs, + double ys, double zs, double pow) { if (ySize == 1) { int A = 0, AA = 0, B = 0, BA = 0; double vv0 = 0, vv2 = 0; diff --git a/targets/minecraft/world/level/levelgen/synth/ImprovedNoise.h b/targets/minecraft/world/level/levelgen/synth/ImprovedNoise.h index 433efba06..6ed8edac3 100644 --- a/targets/minecraft/world/level/levelgen/synth/ImprovedNoise.h +++ b/targets/minecraft/world/level/levelgen/synth/ImprovedNoise.h @@ -29,6 +29,7 @@ public: virtual double getValue(double x, double y); double getValue(double x, double y, double z); - void add(std::vector& buffer, double _x, double _y, double _z, int xSize, - int ySize, int zSize, double xs, double ys, double zs, double pow); + void add(std::vector& buffer, double _x, double _y, double _z, + int xSize, int ySize, int zSize, double xs, double ys, double zs, + double pow); }; diff --git a/targets/minecraft/world/level/levelgen/synth/PerlinNoise.cpp b/targets/minecraft/world/level/levelgen/synth/PerlinNoise.cpp index cdc446a26..eb4c1eb63 100644 --- a/targets/minecraft/world/level/levelgen/synth/PerlinNoise.cpp +++ b/targets/minecraft/world/level/levelgen/synth/PerlinNoise.cpp @@ -51,10 +51,10 @@ double PerlinNoise::getValue(double x, double y, double z) { return value; } -std::vector PerlinNoise::getRegion(std::vector& buffer, int x, int y, int z, - int xSize, int ySize, int zSize, - double xScale, double yScale, - double zScale) { +std::vector PerlinNoise::getRegion(std::vector& buffer, int x, + int y, int z, int xSize, int ySize, + int zSize, double xScale, + double yScale, double zScale) { if (buffer.empty()) buffer = std::vector(xSize * ySize * zSize); else @@ -84,8 +84,9 @@ std::vector PerlinNoise::getRegion(std::vector& buffer, int x, i return buffer; } -std::vector PerlinNoise::getRegion(std::vector& sr, int x, int z, int xSize, - int zSize, double xScale, double zScale, - double pow) { +std::vector PerlinNoise::getRegion(std::vector& sr, int x, + int z, int xSize, int zSize, + double xScale, double zScale, + double pow) { return getRegion(sr, x, 10, z, xSize, 1, zSize, xScale, 1, zScale); } \ No newline at end of file diff --git a/targets/minecraft/world/level/levelgen/synth/PerlinNoise.h b/targets/minecraft/world/level/levelgen/synth/PerlinNoise.h index db1101831..d943867e8 100644 --- a/targets/minecraft/world/level/levelgen/synth/PerlinNoise.h +++ b/targets/minecraft/world/level/levelgen/synth/PerlinNoise.h @@ -24,9 +24,10 @@ public: virtual double getValue(double x, double y); double getValue(double x, double y, double z); - std::vector getRegion(std::vector& buffer, int x, int y, int z, int xSize, - int ySize, int zSize, double xScale, double yScale, - double zScale); - std::vector getRegion(std::vector& sr, int x, int z, int xSize, int zSize, - double xScale, double zScale, double pow); + std::vector getRegion(std::vector& buffer, int x, int y, + int z, int xSize, int ySize, int zSize, + double xScale, double yScale, double zScale); + std::vector getRegion(std::vector& sr, int x, int z, + int xSize, int zSize, double xScale, + double zScale, double pow); }; diff --git a/targets/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.cpp b/targets/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.cpp index 250d472d5..7fa08be8d 100644 --- a/targets/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.cpp +++ b/targets/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.cpp @@ -51,18 +51,18 @@ double PerlinSimplexNoise::getValue(double x, double y, double z) { return value; } -std::vector PerlinSimplexNoise::getRegion(std::vector& buffer, double x, - double y, int xSize, int ySize, - double xScale, double yScale, - double sizeScale) { +std::vector PerlinSimplexNoise::getRegion(std::vector& buffer, + double x, double y, int xSize, + int ySize, double xScale, + double yScale, + double sizeScale) { return getRegion(buffer, x, y, xSize, ySize, xScale, yScale, sizeScale, 0.5); } -std::vector PerlinSimplexNoise::getRegion(std::vector& buffer, double x, - double y, int xSize, int ySize, - double xScale, double yScale, - double sizeScale, double powScale) { +std::vector PerlinSimplexNoise::getRegion( + std::vector& buffer, double x, double y, int xSize, int ySize, + double xScale, double yScale, double sizeScale, double powScale) { xScale /= 1.5; yScale /= 1.5; @@ -83,10 +83,9 @@ std::vector PerlinSimplexNoise::getRegion(std::vector& buffer, d return buffer; } -std::vector PerlinSimplexNoise::getRegion(std::vector& buffer, double x, - double y, double z, int xSize, - int ySize, int zSize, double xScale, - double yScale, double zScale) { +std::vector PerlinSimplexNoise::getRegion( + std::vector& buffer, double x, double y, double z, int xSize, + int ySize, int zSize, double xScale, double yScale, double zScale) { xScale /= 1.5; yScale /= 1.5; diff --git a/targets/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.h b/targets/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.h index 4a0131673..b1be7f0d9 100644 --- a/targets/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.h +++ b/targets/minecraft/world/level/levelgen/synth/PerlinSimplexNoise.h @@ -22,13 +22,15 @@ public: virtual double getValue(double x, double y); double getValue(double x, double y, double z); - std::vector getRegion(std::vector& buffer, double x, double y, int xSize, - int ySize, double xScale, double yScale, - double sizeScale); - std::vector getRegion(std::vector& buffer, double x, double y, int xSize, - int ySize, double xScale, double yScale, - double sizeScale, double powScale); - std::vector getRegion(std::vector& buffer, double x, double y, double z, - int xSize, int ySize, int zSize, double xScale, - double yScale, double zScale); + std::vector getRegion(std::vector& buffer, double x, + double y, int xSize, int ySize, double xScale, + double yScale, double sizeScale); + std::vector getRegion(std::vector& buffer, double x, + double y, int xSize, int ySize, double xScale, + double yScale, double sizeScale, + double powScale); + std::vector getRegion(std::vector& buffer, double x, + double y, double z, int xSize, int ySize, + int zSize, double xScale, double yScale, + double zScale); }; \ No newline at end of file diff --git a/targets/minecraft/world/level/levelgen/synth/SimplexNoise.cpp b/targets/minecraft/world/level/levelgen/synth/SimplexNoise.cpp index c1f298b03..2d81cbc63 100644 --- a/targets/minecraft/world/level/levelgen/synth/SimplexNoise.cpp +++ b/targets/minecraft/world/level/levelgen/synth/SimplexNoise.cpp @@ -243,8 +243,8 @@ double SimplexNoise::getValue(double xin, double yin, double zin) { return 32.0 * (n0 + n1 + n2 + n3); } -void SimplexNoise::add(std::vector& buffer, double _x, double _y, int xSize, - int ySize, double xs, double ys, double pow) { +void SimplexNoise::add(std::vector& buffer, double _x, double _y, + int xSize, int ySize, double xs, double ys, double pow) { int pp = 0; for (int xx = 0; xx < xSize; xx++) { double xin = (_x + xx) * xs + xo; @@ -319,9 +319,9 @@ void SimplexNoise::add(std::vector& buffer, double _x, double _y, int xS } } } -void SimplexNoise::add(std::vector& buffer, double _x, double _y, double _z, - int xSize, int ySize, int zSize, double xs, double ys, - double zs, double pow) { +void SimplexNoise::add(std::vector& buffer, double _x, double _y, + double _z, int xSize, int ySize, int zSize, double xs, + double ys, double zs, double pow) { int pp = 0; for (int xx = 0; xx < xSize; xx++) { double xin = (_x + xx) * xs + xo; diff --git a/targets/minecraft/world/level/levelgen/synth/SimplexNoise.h b/targets/minecraft/world/level/levelgen/synth/SimplexNoise.h index d85d4f389..b3c65d0ca 100644 --- a/targets/minecraft/world/level/levelgen/synth/SimplexNoise.h +++ b/targets/minecraft/world/level/levelgen/synth/SimplexNoise.h @@ -37,8 +37,9 @@ public: // 3D simplex noise double getValue(double xin, double yin, double zin); - void add(std::vector& buffer, double _x, double _y, int xSize, int ySize, - double xs, double ys, double pow); - void add(std::vector& buffer, double _x, double _y, double _z, int xSize, - int ySize, int zSize, double xs, double ys, double zs, double pow); + void add(std::vector& buffer, double _x, double _y, int xSize, + int ySize, double xs, double ys, double pow); + void add(std::vector& buffer, double _x, double _y, double _z, + int xSize, int ySize, int zSize, double xs, double ys, double zs, + double pow); }; diff --git a/targets/minecraft/world/level/newbiome/layer/BiomeInitLayer.cpp b/targets/minecraft/world/level/newbiome/layer/BiomeInitLayer.cpp index ea39d202b..4b37c5a22 100644 --- a/targets/minecraft/world/level/newbiome/layer/BiomeInitLayer.cpp +++ b/targets/minecraft/world/level/newbiome/layer/BiomeInitLayer.cpp @@ -30,7 +30,6 @@ BiomeInitLayer::BiomeInitLayer(int64_t seed, std::shared_ptr parent, } } - std::vector BiomeInitLayer::getArea(int xo, int yo, int w, int h) { std::vector b = parent->getArea(xo, yo, w, h); diff --git a/targets/minecraft/world/level/newbiome/layer/BiomeOverrideLayer.cpp b/targets/minecraft/world/level/newbiome/layer/BiomeOverrideLayer.cpp index b88a67dac..d448bcfe2 100644 --- a/targets/minecraft/world/level/newbiome/layer/BiomeOverrideLayer.cpp +++ b/targets/minecraft/world/level/newbiome/layer/BiomeOverrideLayer.cpp @@ -20,14 +20,16 @@ BiomeOverrideLayer::BiomeOverrideLayer(int seedMixup) : Layer(seedMixup) { // assert(false); app.DebugPrintf("Biome override not found, using plains as default\n"); - memset(m_biomeOverride.data(), Biome::plains->id, m_biomeOverride.size()); + memset(m_biomeOverride.data(), Biome::plains->id, + m_biomeOverride.size()); } else { auto fileSize = std::filesystem::file_size(path); if (fileSize > m_biomeOverride.size()) { app.DebugPrintf("Biomemap binary is too large!!\n"); __debugbreak(); } - file.read(reinterpret_cast(m_biomeOverride.data()), static_cast(fileSize)); + file.read(reinterpret_cast(m_biomeOverride.data()), + static_cast(fileSize)); if (!file) { app.FatalLoadError(); diff --git a/targets/minecraft/world/level/newbiome/layer/FuzzyZoomLayer.cpp b/targets/minecraft/world/level/newbiome/layer/FuzzyZoomLayer.cpp index 1ba6ed9a5..1a87a0d5d 100644 --- a/targets/minecraft/world/level/newbiome/layer/FuzzyZoomLayer.cpp +++ b/targets/minecraft/world/level/newbiome/layer/FuzzyZoomLayer.cpp @@ -44,9 +44,11 @@ std::vector FuzzyZoomLayer::getArea(int xo, int yo, int w, int h) { } std::vector result(w * h); for (int y = 0; y < h; y++) { - std::copy(tmp.begin() + (y + (yo & 1)) * ((unsigned int)pw << 1) + (xo & 1), - tmp.begin() + (y + (yo & 1)) * ((unsigned int)pw << 1) + (xo & 1) + w, - result.begin() + y * w); + std::copy( + tmp.begin() + (y + (yo & 1)) * ((unsigned int)pw << 1) + (xo & 1), + tmp.begin() + (y + (yo & 1)) * ((unsigned int)pw << 1) + (xo & 1) + + w, + result.begin() + y * w); } return result; diff --git a/targets/minecraft/world/level/newbiome/layer/GrowMushroomIslandLayer.cpp b/targets/minecraft/world/level/newbiome/layer/GrowMushroomIslandLayer.cpp index 9293b606c..839b98fd3 100644 --- a/targets/minecraft/world/level/newbiome/layer/GrowMushroomIslandLayer.cpp +++ b/targets/minecraft/world/level/newbiome/layer/GrowMushroomIslandLayer.cpp @@ -13,7 +13,8 @@ GrowMushroomIslandLayer::GrowMushroomIslandLayer(int64_t seedMixup, this->parent = parent; } -std::vector GrowMushroomIslandLayer::getArea(int xo, int yo, int w, int h) { +std::vector GrowMushroomIslandLayer::getArea(int xo, int yo, int w, + int h) { int px = xo - 1; int py = yo - 1; int pw = w + 2; diff --git a/targets/minecraft/world/level/newbiome/layer/Layer.cpp b/targets/minecraft/world/level/newbiome/layer/Layer.cpp index 7f8ab337c..b4d0b20ec 100644 --- a/targets/minecraft/world/level/newbiome/layer/Layer.cpp +++ b/targets/minecraft/world/level/newbiome/layer/Layer.cpp @@ -25,14 +25,14 @@ #include "minecraft/world/level/newbiome/layer/ZoomLayer.h" #include "platform/PlatformServices.h" -std::vector> Layer::getDefaultLayers(int64_t seed, LevelType* levelType) { +std::vector> Layer::getDefaultLayers( + int64_t seed, LevelType* levelType) { // 4J - Some changes moved here from 1.2.3. Temperature & downfall layers // are no longer created & returned, and a debug layer is isn't. For // reference with regard to future merging, things NOT brought forward from // the 1.2.3 version are new layer types that we don't have yet (shores, // swamprivers, region hills etc.) - std::shared_ptr islandLayer = - std::make_shared(1); + std::shared_ptr islandLayer = std::make_shared(1); islandLayer = std::make_shared(2000, islandLayer); islandLayer = std::make_shared(1, islandLayer); islandLayer = std::make_shared(2001, islandLayer); @@ -59,19 +59,16 @@ std::vector> Layer::getDefaultLayers(int64_t seed, LevelT std::shared_ptr biomeLayer = islandLayer; biomeLayer = ZoomLayer::zoom(1000, biomeLayer, 0); - biomeLayer = - std::make_shared(200, biomeLayer, levelType); + biomeLayer = std::make_shared(200, biomeLayer, levelType); biomeLayer = ZoomLayer::zoom(1000, biomeLayer, 2); biomeLayer = std::make_shared(1000, biomeLayer); for (int i = 0; i < zoomLevel; i++) { - biomeLayer = - std::make_shared(1000 + i, biomeLayer); + biomeLayer = std::make_shared(1000 + i, biomeLayer); if (i == 0) - biomeLayer = - std::make_shared(3, biomeLayer); + biomeLayer = std::make_shared(3, biomeLayer); if (i == 0) { // 4J - moved mushroom islands to here. This skips 3 zooms that the @@ -97,11 +94,9 @@ std::vector> Layer::getDefaultLayers(int64_t seed, LevelT // Note - this reduces the size of mushroom islands by turning their // edges into shores. We are doing this at i == 1 rather than i == 0 // as the original does - biomeLayer = - std::make_shared(1000, biomeLayer); + biomeLayer = std::make_shared(1000, biomeLayer); - biomeLayer = - std::make_shared(1000, biomeLayer); + biomeLayer = std::make_shared(1000, biomeLayer); } } @@ -115,8 +110,7 @@ std::vector> Layer::getDefaultLayers(int64_t seed, LevelT if (app.DebugSettingsOn() && app.GetGameSettingsDebugMask(PlatformInput.GetPrimaryPad()) & (1L << eDebugSetting_EnableBiomeOverride)) { - biomeLayer = - std::make_shared(1); + biomeLayer = std::make_shared(1); } #endif #endif diff --git a/targets/minecraft/world/level/newbiome/layer/Layer.h b/targets/minecraft/world/level/newbiome/layer/Layer.h index f7dc364d6..62b836c6f 100644 --- a/targets/minecraft/world/level/newbiome/layer/Layer.h +++ b/targets/minecraft/world/level/newbiome/layer/Layer.h @@ -5,7 +5,6 @@ #include #include - class LevelType; #ifndef _CONTENT_PACKAGE @@ -24,7 +23,8 @@ private: int64_t seedMixup; public: - static std::vector> getDefaultLayers(int64_t seed, LevelType* levelType); + static std::vector> getDefaultLayers( + int64_t seed, LevelType* levelType); Layer(int64_t seedMixup); diff --git a/targets/minecraft/world/level/newbiome/layer/VoronoiZoom.cpp b/targets/minecraft/world/level/newbiome/layer/VoronoiZoom.cpp index 05f2dbec6..c98398079 100644 --- a/targets/minecraft/world/level/newbiome/layer/VoronoiZoom.cpp +++ b/targets/minecraft/world/level/newbiome/layer/VoronoiZoom.cpp @@ -78,8 +78,10 @@ std::vector VoronoiZoom::getArea(int xo, int yo, int w, int h) { } std::vector result(w * h); for (int y = 0; y < h; y++) { - std::copy(tmp.begin() + (y + (yo & (ss - 1))) * ((unsigned)pw << bits) + (xo & (ss - 1)), - tmp.begin() + (y + (yo & (ss - 1))) * ((unsigned)pw << bits) + (xo & (ss - 1)) + w, + std::copy(tmp.begin() + (y + (yo & (ss - 1))) * ((unsigned)pw << bits) + + (xo & (ss - 1)), + tmp.begin() + (y + (yo & (ss - 1))) * ((unsigned)pw << bits) + + (xo & (ss - 1)) + w, result.begin() + y * w); } return result; diff --git a/targets/minecraft/world/level/newbiome/layer/ZoomLayer.cpp b/targets/minecraft/world/level/newbiome/layer/ZoomLayer.cpp index 22e835a04..ac8363867 100644 --- a/targets/minecraft/world/level/newbiome/layer/ZoomLayer.cpp +++ b/targets/minecraft/world/level/newbiome/layer/ZoomLayer.cpp @@ -44,9 +44,11 @@ std::vector ZoomLayer::getArea(int xo, int yo, int w, int h) { } std::vector result(w * h); for (int y = 0; y < h; y++) { - std::copy(tmp.begin() + (y + (yo & 1)) * (unsigned int)(pw << 1) + (xo & 1), - tmp.begin() + (y + (yo & 1)) * (unsigned int)(pw << 1) + (xo & 1) + w, - result.begin() + y * w); + std::copy( + tmp.begin() + (y + (yo & 1)) * (unsigned int)(pw << 1) + (xo & 1), + tmp.begin() + (y + (yo & 1)) * (unsigned int)(pw << 1) + (xo & 1) + + w, + result.begin() + y * w); } return result; } diff --git a/targets/minecraft/world/level/pathfinder/Path.cpp b/targets/minecraft/world/level/pathfinder/Path.cpp index d5718ef51..07730b153 100644 --- a/targets/minecraft/world/level/pathfinder/Path.cpp +++ b/targets/minecraft/world/level/pathfinder/Path.cpp @@ -11,7 +11,8 @@ Path::Path(std::vector& nodes) { index = 0; length = nodes.size(); - // 4J - copying these nodes over from a std::vector (which is an array of Node + // 4J - copying these nodes over from a std::vector (which is an + // array of Node // * references) to just a straight array of Nodes, so that this Path is no // longer dependent of Nodes allocated elsewhere and can handle its own // destruction Note: cameFrom pointer will be useless now but that isn't diff --git a/targets/minecraft/world/level/saveddata/MapItemSavedData.cpp b/targets/minecraft/world/level/saveddata/MapItemSavedData.cpp index 16e922539..c4ad21371 100644 --- a/targets/minecraft/world/level/saveddata/MapItemSavedData.cpp +++ b/targets/minecraft/world/level/saveddata/MapItemSavedData.cpp @@ -48,8 +48,7 @@ MapItemSavedData::HoldingPlayer::HoldingPlayer(std::shared_ptr player, } } -MapItemSavedData::HoldingPlayer::~HoldingPlayer() { -} +MapItemSavedData::HoldingPlayer::~HoldingPlayer() {} std::vector MapItemSavedData::HoldingPlayer::nextUpdatePacket( std::shared_ptr itemInstance) { @@ -67,10 +66,10 @@ std::vector MapItemSavedData::HoldingPlayer::nextUpdatePacket( unsigned int playerDecorationsSize = (int)parent->decorations.size(); unsigned int nonPlayerDecorationsSize = (int)parent->nonPlayerDecorations.size(); - std::vector data = - std::vector((playerDecorationsSize + nonPlayerDecorationsSize) * - DEC_PACKET_BYTES + - 1); + std::vector data = std::vector( + (playerDecorationsSize + nonPlayerDecorationsSize) * + DEC_PACKET_BYTES + + 1); data[0] = 1; for (unsigned int i = 0; i < parent->decorations.size(); i++) { MapDecoration* md = parent->decorations.at(i); @@ -187,7 +186,8 @@ void MapItemSavedData::load(CompoundTag* tag) { std::vector newColors = tag->getByteArray(L"colors"); // 4J - vector manages its own memory, no need to delete old colors // End4J - colors = std::vector(MapItem::IMAGE_WIDTH * MapItem::IMAGE_HEIGHT); + colors = + std::vector(MapItem::IMAGE_WIDTH * MapItem::IMAGE_HEIGHT); int xo = (MapItem::IMAGE_WIDTH - width) / 2; int yo = (MapItem::IMAGE_HEIGHT - height) / 2; for (int y = 0; y < height; y++) { diff --git a/targets/minecraft/world/level/saveddata/MapItemSavedData.h b/targets/minecraft/world/level/saveddata/MapItemSavedData.h index 1dde7d195..672fc803b 100644 --- a/targets/minecraft/world/level/saveddata/MapItemSavedData.h +++ b/targets/minecraft/world/level/saveddata/MapItemSavedData.h @@ -66,7 +66,8 @@ public: HoldingPlayer(std::shared_ptr player, const MapItemSavedData* parent); ~HoldingPlayer(); - std::vector nextUpdatePacket(std::shared_ptr itemInstance); + std::vector nextUpdatePacket( + std::shared_ptr itemInstance); }; public: @@ -101,8 +102,9 @@ public: void tickCarriedBy(std::shared_ptr player, std::shared_ptr item); - std::vector getUpdatePacket(std::shared_ptr itemInstance, - Level* level, std::shared_ptr player); + std::vector getUpdatePacket( + std::shared_ptr itemInstance, Level* level, + std::shared_ptr player); using SavedData::setDirty; void setDirty(int x, int y0, int y1); diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileInputStream.cpp b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileInputStream.cpp index 8eb76e536..004e0a21b 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileInputStream.cpp +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileInputStream.cpp @@ -58,7 +58,7 @@ int ConsoleSaveFileInputStream::read(std::vector& b) { bool result = m_saveFile->readFile(m_file, - b.data(), // data buffer + b.data(), // data buffer b.size(), // number of bytes to read &numberOfBytesRead // number of bytes read ); @@ -81,8 +81,8 @@ int ConsoleSaveFileInputStream::read(std::vector& b) { // b len - the maximum number of bytes read. Returns: the total number of bytes // read into the buffer, or -1 if there is no more data because the end of the // file has been reached. -int ConsoleSaveFileInputStream::read(std::vector& b, unsigned int offset, - unsigned int length) { +int ConsoleSaveFileInputStream::read(std::vector& b, + unsigned int offset, unsigned int length) { // 4J Stu - We don't want to read any more than the array buffer can hold assert(length <= (b.size() - offset)); diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileInputStream.h b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileInputStream.h index 37fac3221..10bccb34b 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileInputStream.h +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileInputStream.h @@ -17,7 +17,8 @@ public: ConsoleSaveFileInputStream(ConsoleSaveFile* saveFile, FileEntry* file); virtual int read(); virtual int read(std::vector& b); - virtual int read(std::vector& b, unsigned int offset, unsigned int length); + virtual int read(std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual int64_t skip(int64_t n) { return n; } diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp index e0518b996..0386a0a4b 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOriginal.cpp @@ -504,7 +504,7 @@ void ConsoleSaveFileOriginal::MoveDataBeyond( uiCopyEnd = uiFromEnd; } memcpy((void*)(uiCopyStart + nNumberOfBytesToWrite), - (void*)uiCopyStart, uiCopyEnd - uiCopyStart); + (void*)uiCopyStart, uiCopyEnd - uiCopyStart); } } } else { @@ -599,7 +599,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { compLength = 0; // Pre-calculate the buffer size required for the compressed data - // Save the start time + // Save the start time const auto startTime = std::chrono::steady_clock::now(); Compression::getCompression()->Compress(nullptr, &compLength, pvSaveMem, fileSize); @@ -608,7 +608,6 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { .count(); app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime); - // We add 4 bytes to the start so that we can signal compressed data // And another 4 bytes to store the decompressed data size @@ -620,7 +619,7 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { if (compData != nullptr) { // Re-compress all save data before we save it to disk - // Save the start time + // Save the start time const auto startTime = std::chrono::steady_clock::now(); Compression::getCompression()->Compress(compData + 8, &compLength, pvSaveMem, fileSize); @@ -629,7 +628,6 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { .count(); app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime); - std::fill_n(compData, 8, std::uint8_t{0}); int saveVer = 0; @@ -674,8 +672,8 @@ void ConsoleSaveFileOriginal::Flush(bool autosave, bool updateThumbnail) { #ifdef _WINDOWS64 // set the icon and save image PlatformStorage.SetSaveImages(pbThumbnailData, dwThumbnailDataSize, - pbDataSaveImage, dwDataSizeSaveImage, - bTextMetadata, iTextMetadataBytes); + pbDataSaveImage, dwDataSizeSaveImage, + bTextMetadata, iTextMetadataBytes); app.DebugPrintf("Save thumbnail size %d\n", dwThumbnailDataSize); // save the data diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.cpp b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.cpp index de97eb70f..bfc27c78e 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.cpp +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.cpp @@ -65,7 +65,7 @@ void ConsoleSaveFileOutputStream::write(const std::vector& b) { bool result = m_saveFile->writeFile(m_file, - b.data(), // data buffer + b.data(), // data buffer b.size(), // number of bytes to write &numberOfBytesWritten // number of bytes written ); @@ -80,7 +80,8 @@ void ConsoleSaveFileOutputStream::write(const std::vector& b) { // Writes len bytes from the specified byte array starting at offset off to this // file output stream. Parameters: b - the data. off - the start offset in the // data. len - the number of bytes to write. -void ConsoleSaveFileOutputStream::write(const std::vector& b, unsigned int offset, +void ConsoleSaveFileOutputStream::write(const std::vector& b, + unsigned int offset, unsigned int length) { // 4J Stu - We don't want to write any more than the array buffer holds assert(length <= (b.size() - offset)); diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.h b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.h index 4d3f849d1..ee534232e 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.h +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileOutputStream.h @@ -17,7 +17,8 @@ public: ConsoleSaveFileOutputStream(ConsoleSaveFile* saveFile, FileEntry* file); virtual void write(unsigned int b); virtual void write(const std::vector& b); - virtual void write(const std::vector& b, unsigned int offset, unsigned int length); + virtual void write(const std::vector& b, unsigned int offset, + unsigned int length); virtual void close(); virtual void flush() {} diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp index 48da5531e..3ba0d8594 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/ConsoleSaveFileSplit.cpp @@ -445,8 +445,8 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, unsigned int regionSizeCompressed; PlatformStorage.GetSubfileDetails(i, (int*)®ionIndex, - (void**)®ionDataCompressed, - ®ionSizeCompressed); + (void**)®ionDataCompressed, + ®ionSizeCompressed); RegionFileReference* regionFileRef = new RegionFileReference( i, regionIndex, regionSizeCompressed, regionDataCompressed); @@ -507,7 +507,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, // 4J Stu - Saves created between 2/12/2011 and 7/12/2011 will // have this problem app.DebugPrintf("Invalid save data format\n"); - memset(pvSaveMem, 0, fileSize); + memset(pvSaveMem, 0, fileSize); // Clear the first 8 bytes that reference the header header.WriteHeader(pvSaveMem); } else { @@ -544,7 +544,7 @@ void ConsoleSaveFileSplit::_init(const std::wstring& fileName, void* pvSaveData, #if !defined(_CONTENT_PACKAGE) __debugbreak(); #endif - memset(pvSaveMem, 0, fileSize); + memset(pvSaveMem, 0, fileSize); // Clear the first 8 bytes that reference the header header.WriteHeader(pvSaveMem); } @@ -690,8 +690,7 @@ void ConsoleSaveFileSplit::PrepareForWrite(FileEntry* file, // bytesToGrowBy = 1024; // Move all the data beyond us - MoveDataBeyond(file, bytesToGrowBy); - + MoveDataBeyond(file, bytesToGrowBy); // Update our length if (file->data.length < 0) file->data.length = 0; @@ -973,8 +972,8 @@ void ConsoleSaveFileSplit::tick() { // as %d bytes\n",regionRef->fileEntry->getRegionFileIndex(), // regionRef->dataCompressedSize); PlatformStorage.UpdateSubfile(regionRef->index, - regionRef->dataCompressed, - regionRef->dataCompressedSize); + regionRef->dataCompressed, + regionRef->dataCompressedSize); regionRef->dirty = false; regionRef->lastWritten = System::currentTimeMillis(); @@ -1103,7 +1102,7 @@ void ConsoleSaveFileSplit::MoveDataBeyond(FileEntry* file, uiCopyEnd = uiFromEnd; } memcpy((void*)(uiCopyStart + nNumberOfBytesToWrite), - (void*)uiCopyStart, uiCopyEnd - uiCopyStart); + (void*)uiCopyStart, uiCopyEnd - uiCopyStart); } } } else { @@ -1244,7 +1243,7 @@ void ConsoleSaveFileSplit::processSubfilesForWrite() { if (region->dirty) { region->Compress(); PlatformStorage.UpdateSubfile(region->index, region->dataCompressed, - region->dataCompressedSize); + region->dataCompressedSize); region->dirty = false; region->lastWritten = System::currentTimeMillis(); } @@ -1314,16 +1313,16 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { compLength = 0; // Pre-calculate the buffer size required for the compressed data - // Save the start time + // Save the start time qwTime = PlatformTime::QueryPerformanceCounter(); Compression::getCompression()->Compress(nullptr, &compLength, pvSaveMem, fileSize); qwNewTime = PlatformTime::QueryPerformanceCounter(); - fElapsedTime = static_cast(PlatformTime::ElapsedSeconds(qwTime, qwNewTime)); + fElapsedTime = + static_cast(PlatformTime::ElapsedSeconds(qwTime, qwNewTime)); app.DebugPrintf("Check buffer size: Elapsed time %f\n", fElapsedTime); - // We add 4 bytes to the start so that we can signal compressed data // And another 4 bytes to store the decompressed data size @@ -1335,18 +1334,18 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { if (compData != nullptr) { // Re-compress all save data before we save it to disk - // Save the start time + // Save the start time qwTime = PlatformTime::QueryPerformanceCounter(); Compression::getCompression()->Compress(compData + 8, &compLength, pvSaveMem, fileSize); qwNewTime = PlatformTime::QueryPerformanceCounter(); - fElapsedTime = static_cast(PlatformTime::ElapsedSeconds(qwTime, qwNewTime)); + fElapsedTime = + static_cast(PlatformTime::ElapsedSeconds(qwTime, qwNewTime)); app.DebugPrintf("Compress: Elapsed time %f\n", fElapsedTime); - - memset(compData, 0, 8); + memset(compData, 0, 8); int saveVer = 0; memcpy(compData, &saveVer, sizeof(int)); memcpy(compData + 4, &fileSize, sizeof(int)); @@ -1362,7 +1361,7 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { unsigned int dwDataSizeSaveImage = 0; std::uint8_t bTextMetadata[88]; - memset(bTextMetadata, 0, 88); + memset(bTextMetadata, 0, 88); int64_t seed = 0; bool hasSeed = false; @@ -1382,8 +1381,8 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { // set the icon and save image PlatformStorage.SetSaveImages(pbThumbnailData, dwThumbnailDataSize, - pbDataSaveImage, dwDataSizeSaveImage, - bTextMetadata, iTextMetadataBytes); + pbDataSaveImage, dwDataSizeSaveImage, + bTextMetadata, iTextMetadataBytes); app.DebugPrintf("Save thumbnail size %d\n", dwThumbnailDataSize); } @@ -1392,8 +1391,8 @@ void ConsoleSaveFileSplit::Flush(bool autosave, bool updateThumbnail) { PlatformStorage.GetSaveUniqueNumber(&saveOrCheckpointId); // save the data - PlatformStorage.SaveSaveData(&ConsoleSaveFileSplit::SaveSaveDataCallback, - this); + PlatformStorage.SaveSaveData( + &ConsoleSaveFileSplit::SaveSaveDataCallback, this); #if !defined(_CONTENT_PACKAGE) if (app.DebugSettingsOn()) { if (app.GetWriteSavesToFolderEnabled()) { diff --git a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.h b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.h index 8160d4095..5ae95f90a 100644 --- a/targets/minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.h +++ b/targets/minecraft/world/level/storage/ConsoleSaveFileIO/FileHeader.h @@ -140,7 +140,8 @@ public: void updateLastModifiedTime() { auto now = std::chrono::system_clock::now().time_since_epoch(); - data.lastModifiedTime = std::chrono::duration_cast(now).count(); + data.lastModifiedTime = + std::chrono::duration_cast(now).count(); } /* diff --git a/targets/minecraft/world/level/storage/DirectoryLevelStorage.cpp b/targets/minecraft/world/level/storage/DirectoryLevelStorage.cpp index c75a54818..143278310 100644 --- a/targets/minecraft/world/level/storage/DirectoryLevelStorage.cpp +++ b/targets/minecraft/world/level/storage/DirectoryLevelStorage.cpp @@ -45,8 +45,8 @@ const std::wstring DirectoryLevelStorage::sc_szPlayerDir(L"players/"); _MapDataMappings::_MapDataMappings() { - memset(xuids, 0, sizeof(PlayerUID) * MAXIMUM_MAP_SAVE_DATA); - memset(dimensions, 0, sizeof(uint8_t) * (MAXIMUM_MAP_SAVE_DATA / 4)); + memset(xuids, 0, sizeof(PlayerUID) * MAXIMUM_MAP_SAVE_DATA); + memset(dimensions, 0, sizeof(uint8_t) * (MAXIMUM_MAP_SAVE_DATA / 4)); } int _MapDataMappings::getDimension(int id) { @@ -104,8 +104,8 @@ void _MapDataMappings::setMapping(int id, PlayerUID xuid, int dimension) { // Old version the only used 1 bit for dimension indexing _MapDataMappings_old::_MapDataMappings_old() { - memset(xuids, 0, sizeof(PlayerUID) * MAXIMUM_MAP_SAVE_DATA); - memset(dimensions, 0, sizeof(uint8_t) * (MAXIMUM_MAP_SAVE_DATA / 8)); + memset(xuids, 0, sizeof(PlayerUID) * MAXIMUM_MAP_SAVE_DATA); + memset(dimensions, 0, sizeof(uint8_t) * (MAXIMUM_MAP_SAVE_DATA / 8)); } int _MapDataMappings_old::getDimension(int id) { @@ -651,7 +651,7 @@ void DirectoryLevelStorage::saveMapIdLookup() { } dos.write(m_usedMappings); m_saveFile->writeFile(fileEntry, - baos.buf.data(), // data buffer + baos.buf.data(), // data buffer baos.size(), // number of bytes to write &NumberOfBytesWritten // number of bytes written ); diff --git a/targets/minecraft/world/level/tile/BrewingStandTile.h b/targets/minecraft/world/level/tile/BrewingStandTile.h index 3cb606a51..12c5233f9 100644 --- a/targets/minecraft/world/level/tile/BrewingStandTile.h +++ b/targets/minecraft/world/level/tile/BrewingStandTile.h @@ -21,7 +21,8 @@ public: virtual std::shared_ptr newTileEntity(Level* level); virtual bool isCubeShaped(); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual void updateDefaultShape(); virtual bool use(Level* level, int x, int y, int z, std::shared_ptr player, int clickedFace, diff --git a/targets/minecraft/world/level/tile/CauldronTile.cpp b/targets/minecraft/world/level/tile/CauldronTile.cpp index 2d456fe9d..9d439ea60 100644 --- a/targets/minecraft/world/level/tile/CauldronTile.cpp +++ b/targets/minecraft/world/level/tile/CauldronTile.cpp @@ -53,7 +53,8 @@ Icon* CauldronTile::getTexture(const std::wstring& name) { } void CauldronTile::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) { + std::vector* boxes, + std::shared_ptr source) { setShape(0, 0, 0, 1, 5.0f / 16.0f, 1); Tile::addAABBs(level, x, y, z, box, boxes, source); float thickness = 2.0f / 16.0f; diff --git a/targets/minecraft/world/level/tile/CauldronTile.h b/targets/minecraft/world/level/tile/CauldronTile.h index 4af09747b..7c23da0ed 100644 --- a/targets/minecraft/world/level/tile/CauldronTile.h +++ b/targets/minecraft/world/level/tile/CauldronTile.h @@ -24,7 +24,8 @@ public: void registerIcons(IconRegister* iconRegister); static Icon* getTexture(const std::wstring& name); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual void updateDefaultShape(); virtual bool isSolidRender(bool isServerLevel = false); virtual int getRenderShape(); diff --git a/targets/minecraft/world/level/tile/ChestTile.cpp b/targets/minecraft/world/level/tile/ChestTile.cpp index 32c518b7d..f31fd93d6 100644 --- a/targets/minecraft/world/level/tile/ChestTile.cpp +++ b/targets/minecraft/world/level/tile/ChestTile.cpp @@ -213,12 +213,12 @@ void ChestTile::onRemove(Level* level, int x, int y, int z, int id, int data) { item->count -= count; std::shared_ptr newItem = - std::make_shared( - item->id, count, item->getAuxValue()); + std::make_shared(item->id, count, + item->getAuxValue()); newItem->set4JData(item->get4JData()); std::shared_ptr itemEntity = - std::make_shared( - level, x + xo, y + yo, z + zo, newItem); + std::make_shared(level, x + xo, y + yo, + z + zo, newItem); float pow = 0.05f; itemEntity->xd = (float)random->nextGaussian() * pow; itemEntity->yd = (float)random->nextGaussian() * pow + 0.2f; @@ -317,8 +317,7 @@ std::shared_ptr ChestTile::getContainer(Level* level, int x, int y, } std::shared_ptr ChestTile::newTileEntity(Level* level) { - std::shared_ptr retval = - std::make_shared(); + std::shared_ptr retval = std::make_shared(); return retval; } diff --git a/targets/minecraft/world/level/tile/CocoaTile.cpp b/targets/minecraft/world/level/tile/CocoaTile.cpp index 598db457b..823b75456 100644 --- a/targets/minecraft/world/level/tile/CocoaTile.cpp +++ b/targets/minecraft/world/level/tile/CocoaTile.cpp @@ -150,8 +150,8 @@ void CocoaTile::spawnResources(Level* level, int x, int y, int z, int data, } for (int i = 0; i < count; i++) { popResource(level, x, y, z, - std::make_shared( - Item::dye_powder, 1, DyePowderItem::BROWN)); + std::make_shared(Item::dye_powder, 1, + DyePowderItem::BROWN)); } } diff --git a/targets/minecraft/world/level/tile/DispenserTile.cpp b/targets/minecraft/world/level/tile/DispenserTile.cpp index 5e63f3f46..9ab0445cc 100644 --- a/targets/minecraft/world/level/tile/DispenserTile.cpp +++ b/targets/minecraft/world/level/tile/DispenserTile.cpp @@ -199,12 +199,12 @@ void DispenserTile::onRemove(Level* level, int x, int y, int z, int id, item->count -= count; std::shared_ptr newItem = - std::make_shared( - item->id, count, item->getAuxValue()); + std::make_shared(item->id, count, + item->getAuxValue()); newItem->set4JData(item->get4JData()); std::shared_ptr itemEntity = - std::make_shared( - level, x + xo, y + yo, z + zo, newItem); + std::make_shared(level, x + xo, y + yo, + z + zo, newItem); float pow = 0.05f; itemEntity->xd = (float)random->nextGaussian() * pow; itemEntity->yd = (float)random->nextGaussian() * pow + 0.2f; diff --git a/targets/minecraft/world/level/tile/FenceTile.cpp b/targets/minecraft/world/level/tile/FenceTile.cpp index 150985b76..37aef1308 100644 --- a/targets/minecraft/world/level/tile/FenceTile.cpp +++ b/targets/minecraft/world/level/tile/FenceTile.cpp @@ -12,7 +12,8 @@ FenceTile::FenceTile(int id, const std::wstring& texture, Material* material) } void FenceTile::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) { + std::vector* boxes, + std::shared_ptr source) { bool n = connectsTo(level, x, y, z - 1); bool s = connectsTo(level, x, y, z + 1); bool w = connectsTo(level, x - 1, y, z); diff --git a/targets/minecraft/world/level/tile/FenceTile.h b/targets/minecraft/world/level/tile/FenceTile.h index 9af0664ba..a826e13d6 100644 --- a/targets/minecraft/world/level/tile/FenceTile.h +++ b/targets/minecraft/world/level/tile/FenceTile.h @@ -15,7 +15,8 @@ private: public: FenceTile(int id, const std::wstring& texture, Material* material); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual void updateShape( LevelSource* level, int x, int y, int z, int forceData = -1, std::shared_ptr forceEntity = std::shared_ptr< diff --git a/targets/minecraft/world/level/tile/FurnaceTile.cpp b/targets/minecraft/world/level/tile/FurnaceTile.cpp index 8eb21f125..2e464c5a9 100644 --- a/targets/minecraft/world/level/tile/FurnaceTile.cpp +++ b/targets/minecraft/world/level/tile/FurnaceTile.cpp @@ -192,12 +192,12 @@ void FurnaceTile::onRemove(Level* level, int x, int y, int z, int id, #endif std::shared_ptr newItem = - std::make_shared( - item->id, count, item->getAuxValue()); + std::make_shared(item->id, count, + item->getAuxValue()); newItem->set4JData(item->get4JData()); std::shared_ptr itemEntity = - std::make_shared( - level, x + xo, y + yo, z + zo, newItem); + std::make_shared(level, x + xo, y + yo, + z + zo, newItem); float pow = 0.05f; itemEntity->xd = (float)random->nextGaussian() * pow; itemEntity->yd = diff --git a/targets/minecraft/world/level/tile/HalfSlabTile.cpp b/targets/minecraft/world/level/tile/HalfSlabTile.cpp index c4f8355dd..2ac53c616 100644 --- a/targets/minecraft/world/level/tile/HalfSlabTile.cpp +++ b/targets/minecraft/world/level/tile/HalfSlabTile.cpp @@ -44,7 +44,8 @@ void HalfSlabTile::updateDefaultShape() { } void HalfSlabTile::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) { + std::vector* boxes, + std::shared_ptr source) { updateShape(level, x, y, z); Tile::addAABBs(level, x, y, z, box, boxes, source); } diff --git a/targets/minecraft/world/level/tile/HalfSlabTile.h b/targets/minecraft/world/level/tile/HalfSlabTile.h index b8c8381bf..7b99399f8 100644 --- a/targets/minecraft/world/level/tile/HalfSlabTile.h +++ b/targets/minecraft/world/level/tile/HalfSlabTile.h @@ -22,7 +22,8 @@ public: TileEntity>()); // 4J added forceData, forceEntity param virtual void updateDefaultShape(); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual bool isSolidRender(bool isServerLevel); virtual int getPlacedOnFaceDataValue(Level* level, int x, int y, int z, int face, float clickX, float clickY, diff --git a/targets/minecraft/world/level/tile/HopperTile.cpp b/targets/minecraft/world/level/tile/HopperTile.cpp index e607860a6..b8a8e7f35 100644 --- a/targets/minecraft/world/level/tile/HopperTile.cpp +++ b/targets/minecraft/world/level/tile/HopperTile.cpp @@ -30,7 +30,8 @@ void HopperTile::updateShape(LevelSource* level, int x, int y, int z, } void HopperTile::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) { + std::vector* boxes, + std::shared_ptr source) { setShape(0, 0, 0, 1, 10.0f / 16.0f, 1); BaseEntityTile::addAABBs(level, x, y, z, box, boxes, source); float thickness = 2.0f / 16.0f; diff --git a/targets/minecraft/world/level/tile/HopperTile.h b/targets/minecraft/world/level/tile/HopperTile.h index ced60675e..4c953aa64 100644 --- a/targets/minecraft/world/level/tile/HopperTile.h +++ b/targets/minecraft/world/level/tile/HopperTile.h @@ -38,7 +38,8 @@ public: std::shared_ptr forceEntity = std::shared_ptr()); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual int getPlacedOnFaceDataValue(Level* level, int x, int y, int z, int face, float clickX, float clickY, float clickZ, int itemValue); diff --git a/targets/minecraft/world/level/tile/LeafTile.cpp b/targets/minecraft/world/level/tile/LeafTile.cpp index ca51210a9..7dec96993 100644 --- a/targets/minecraft/world/level/tile/LeafTile.cpp +++ b/targets/minecraft/world/level/tile/LeafTile.cpp @@ -273,8 +273,8 @@ void LeafTile::playerDestroy(Level* level, std::shared_ptr player, // drop leaf block instead of sapling popResource(level, x, y, z, - std::make_shared( - Tile::leaves_Id, 1, data & LEAF_TYPE_MASK)); + std::make_shared(Tile::leaves_Id, 1, + data & LEAF_TYPE_MASK)); } else { TransparentTile::playerDestroy(level, player, x, y, z, data); } diff --git a/targets/minecraft/world/level/tile/SkullTile.cpp b/targets/minecraft/world/level/tile/SkullTile.cpp index 5cd8ca586..7713b093e 100644 --- a/targets/minecraft/world/level/tile/SkullTile.cpp +++ b/targets/minecraft/world/level/tile/SkullTile.cpp @@ -185,8 +185,8 @@ void SkullTile::checkMobSpawn(Level* level, int x, int y, int z, std::make_shared( Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER); std::shared_ptr itemEntity = - std::make_shared( - level, x, y, z + zo + 1, itemInstance); + std::make_shared(level, x, y, z + zo + 1, + itemInstance); level->addEntity(itemEntity); } @@ -266,8 +266,8 @@ void SkullTile::checkMobSpawn(Level* level, int x, int y, int z, std::make_shared( Item::skull_Id, 3, SkullTileEntity::TYPE_WITHER); std::shared_ptr itemEntity = - std::make_shared( - level, x + xo + 1, y, z, itemInstance); + std::make_shared(level, x + xo + 1, y, z, + itemInstance); level->addEntity(itemEntity); } diff --git a/targets/minecraft/world/level/tile/StairTile.cpp b/targets/minecraft/world/level/tile/StairTile.cpp index 0d742b5f4..6df1a007e 100644 --- a/targets/minecraft/world/level/tile/StairTile.cpp +++ b/targets/minecraft/world/level/tile/StairTile.cpp @@ -273,7 +273,8 @@ bool StairTile::setInnerPieceShape(LevelSource* level, int x, int y, int z) { } void StairTile::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) { + std::vector* boxes, + std::shared_ptr source) { setBaseShape(level, x, y, z); Tile::addAABBs(level, x, y, z, box, boxes, source); diff --git a/targets/minecraft/world/level/tile/StairTile.h b/targets/minecraft/world/level/tile/StairTile.h index 73ae69061..e81643e18 100644 --- a/targets/minecraft/world/level/tile/StairTile.h +++ b/targets/minecraft/world/level/tile/StairTile.h @@ -51,8 +51,8 @@ private: public: bool setStepShape(LevelSource* level, int x, int y, int z); bool setInnerPieceShape(LevelSource* level, int x, int y, int z); - void addAABBs(Level* level, int x, int y, int z, AABB* box, std::vector* boxes, - std::shared_ptr source); + void addAABBs(Level* level, int x, int y, int z, AABB* box, + std::vector* boxes, std::shared_ptr source); /** DELEGATES: **/ public: diff --git a/targets/minecraft/world/level/tile/StemTile.cpp b/targets/minecraft/world/level/tile/StemTile.cpp index 036c02a05..c8b02ba37 100644 --- a/targets/minecraft/world/level/tile/StemTile.cpp +++ b/targets/minecraft/world/level/tile/StemTile.cpp @@ -187,8 +187,7 @@ void StemTile::spawnResources(Level* level, int x, int y, int z, int data, if (fruit == Tile::pumpkin) seed = Item::seeds_pumpkin; if (fruit == Tile::melon) seed = Item::seeds_melon; for (int i = 0; i < 3; i++) { - popResource(level, x, y, z, - std::make_shared(seed)); + popResource(level, x, y, z, std::make_shared(seed)); } } diff --git a/targets/minecraft/world/level/tile/TheEndPortalFrameTile.h b/targets/minecraft/world/level/tile/TheEndPortalFrameTile.h index 0260894bb..a67f0bd1c 100644 --- a/targets/minecraft/world/level/tile/TheEndPortalFrameTile.h +++ b/targets/minecraft/world/level/tile/TheEndPortalFrameTile.h @@ -23,7 +23,8 @@ public: virtual int getRenderShape(); virtual void updateDefaultShape(); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); static bool hasEye(int data); virtual int getResource(int data, Random* random, int playerBonusLevel); virtual void setPlacedBy(Level* level, int x, int y, int z, diff --git a/targets/minecraft/world/level/tile/ThinFenceTile.cpp b/targets/minecraft/world/level/tile/ThinFenceTile.cpp index 6e943bfa0..b816f9e92 100644 --- a/targets/minecraft/world/level/tile/ThinFenceTile.cpp +++ b/targets/minecraft/world/level/tile/ThinFenceTile.cpp @@ -42,7 +42,8 @@ bool ThinFenceTile::shouldRenderFace(LevelSource* level, int x, int y, int z, } void ThinFenceTile::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) { + std::vector* boxes, + std::shared_ptr source) { bool n = attachsTo(level->getTile(x, y, z - 1)); bool s = attachsTo(level->getTile(x, y, z + 1)); bool w = attachsTo(level->getTile(x - 1, y, z)); diff --git a/targets/minecraft/world/level/tile/ThinFenceTile.h b/targets/minecraft/world/level/tile/ThinFenceTile.h index 8722bac79..d919dad6e 100644 --- a/targets/minecraft/world/level/tile/ThinFenceTile.h +++ b/targets/minecraft/world/level/tile/ThinFenceTile.h @@ -25,7 +25,8 @@ public: virtual bool shouldRenderFace(LevelSource* level, int x, int y, int z, int face); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual void updateDefaultShape(); virtual void updateShape( LevelSource* level, int x, int y, int z, int forceData = -1, diff --git a/targets/minecraft/world/level/tile/Tile.h b/targets/minecraft/world/level/tile/Tile.h index bdfb7622c..83c7547fe 100644 --- a/targets/minecraft/world/level/tile/Tile.h +++ b/targets/minecraft/world/level/tile/Tile.h @@ -639,7 +639,8 @@ public: virtual Icon* getTexture(int face); virtual AABB getTileAABB(Level* level, int x, int y, int z); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual std::optional getAABB(Level* level, int x, int y, int z); virtual bool isSolidRender( bool isServerLevel = false); // 4J - Added isServerLevel param diff --git a/targets/minecraft/world/level/tile/TopSnowTile.cpp b/targets/minecraft/world/level/tile/TopSnowTile.cpp index 38107e4e7..08e3e61f5 100644 --- a/targets/minecraft/world/level/tile/TopSnowTile.cpp +++ b/targets/minecraft/world/level/tile/TopSnowTile.cpp @@ -92,9 +92,8 @@ void TopSnowTile::playerDestroy(Level* level, std::shared_ptr player, int x, int y, int z, int data) { int type = Item::snowBall->id; int height = data & HEIGHT_MASK; - popResource( - level, x, y, z, - std::make_shared(type, height + 1, 0)); + popResource(level, x, y, z, + std::make_shared(type, height + 1, 0)); level->removeTile(x, y, z); } diff --git a/targets/minecraft/world/level/tile/VineTile.cpp b/targets/minecraft/world/level/tile/VineTile.cpp index c9295ad7c..4f948c55b 100644 --- a/targets/minecraft/world/level/tile/VineTile.cpp +++ b/targets/minecraft/world/level/tile/VineTile.cpp @@ -379,9 +379,8 @@ void VineTile::playerDestroy(Level* level, std::shared_ptr player, GenericStats::param_blocksMined(id, data, 1)); // drop leaf block instead of sapling - popResource( - level, x, y, z, - std::make_shared(Tile::vine, 1, 0)); + popResource(level, x, y, z, + std::make_shared(Tile::vine, 1, 0)); } else { Tile::playerDestroy(level, player, x, y, z, data); } diff --git a/targets/minecraft/world/level/tile/WaterLilyTile.cpp b/targets/minecraft/world/level/tile/WaterLilyTile.cpp index b679131f9..bba48bd5c 100644 --- a/targets/minecraft/world/level/tile/WaterLilyTile.cpp +++ b/targets/minecraft/world/level/tile/WaterLilyTile.cpp @@ -27,7 +27,8 @@ void WaterlilyTile::updateDefaultShape() { int WaterlilyTile::getRenderShape() { return Tile::SHAPE_LILYPAD; } void WaterlilyTile::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) { + std::vector* boxes, + std::shared_ptr source) { if (source == nullptr || !source->instanceof(eTYPE_BOAT)) { Bush::addAABBs(level, x, y, z, box, boxes, source); } diff --git a/targets/minecraft/world/level/tile/WaterLilyTile.h b/targets/minecraft/world/level/tile/WaterLilyTile.h index e35d7b419..1e906c50c 100644 --- a/targets/minecraft/world/level/tile/WaterLilyTile.h +++ b/targets/minecraft/world/level/tile/WaterLilyTile.h @@ -14,7 +14,8 @@ public: virtual int getRenderShape(); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual std::optional getAABB(Level* level, int x, int y, int z); virtual int getColor() const; virtual int getColor(int auxData); diff --git a/targets/minecraft/world/level/tile/entity/BeaconTileEntity.cpp b/targets/minecraft/world/level/tile/entity/BeaconTileEntity.cpp index 2e761f1fe..1023f28f9 100644 --- a/targets/minecraft/world/level/tile/entity/BeaconTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/BeaconTileEntity.cpp @@ -246,8 +246,8 @@ std::shared_ptr BeaconTileEntity::removeItem(unsigned int slot, return returnItem; } else { paymentItem->count -= count; - return std::make_shared( - paymentItem->id, count, paymentItem->getAuxValue()); + return std::make_shared(paymentItem->id, count, + paymentItem->getAuxValue()); } } return nullptr; diff --git a/targets/minecraft/world/level/tile/entity/BrewingStandTileEntity.cpp b/targets/minecraft/world/level/tile/entity/BrewingStandTileEntity.cpp index 2b2b1904d..30ab7ae6f 100644 --- a/targets/minecraft/world/level/tile/entity/BrewingStandTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/BrewingStandTileEntity.cpp @@ -12,7 +12,8 @@ int slotsForUp[] = {BrewingStandTileEntity::INGREDIENT_SLOT}; int slotsForOtherFaces[] = {0, 1, 2}; -std::vector BrewingStandTileEntity::SLOTS_FOR_UP = std::vector(slotsForUp, slotsForUp + 1); +std::vector BrewingStandTileEntity::SLOTS_FOR_UP = + std::vector(slotsForUp, slotsForUp + 1); std::vector BrewingStandTileEntity::SLOTS_FOR_OTHER_FACES = std::vector(slotsForOtherFaces, slotsForOtherFaces + 3); diff --git a/targets/minecraft/world/level/tile/entity/ChestTileEntity.cpp b/targets/minecraft/world/level/tile/entity/ChestTileEntity.cpp index b8a1f9ae8..1711a67fe 100644 --- a/targets/minecraft/world/level/tile/entity/ChestTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/ChestTileEntity.cpp @@ -48,9 +48,7 @@ ChestTileEntity::ChestTileEntity(int type, bool isBonusChest /* = false*/) this->type = type; } -ChestTileEntity::~ChestTileEntity() { - delete items; -} +ChestTileEntity::~ChestTileEntity() { delete items; } unsigned int ChestTileEntity::getContainerSize() { return 9 * 3; } @@ -246,7 +244,7 @@ void ChestTileEntity::tick() { float range = 5; AABB player_aabb(x - range, y - range, z - range, x + 1 + range, y + 1 + range, z + 1 + range); - std::vector >* players = + std::vector>* players = level->getEntitiesOfClass(typeid(Player), &player_aabb); for (auto it = players->begin(); it != players->end(); ++it) { std::shared_ptr player = diff --git a/targets/minecraft/world/level/tile/entity/DispenserTileEntity.cpp b/targets/minecraft/world/level/tile/entity/DispenserTileEntity.cpp index 4c43ff7fc..d33b09821 100644 --- a/targets/minecraft/world/level/tile/entity/DispenserTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/DispenserTileEntity.cpp @@ -14,9 +14,7 @@ DispenserTileEntity::DispenserTileEntity() : TileEntity() { name = L""; } -DispenserTileEntity::~DispenserTileEntity() { - delete random; -} +DispenserTileEntity::~DispenserTileEntity() { delete random; } unsigned int DispenserTileEntity::getContainerSize() { return 9; } diff --git a/targets/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp b/targets/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp index d2439f18f..18e577379 100644 --- a/targets/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/EnchantmentTableTileEntity.cpp @@ -62,12 +62,12 @@ void EnchantmentTableEntity::tick() { } while (rot >= std::numbers::pi) rot -= std::numbers::pi * 2; - while (rot < -std::numbers::pi ) rot += std::numbers::pi * 2; + while (rot < -std::numbers::pi) rot += std::numbers::pi * 2; while (tRot >= std::numbers::pi) tRot -= std::numbers::pi * 2; - while (tRot < -std::numbers::pi ) tRot += std::numbers::pi * 2; + while (tRot < -std::numbers::pi) tRot += std::numbers::pi * 2; float rotDir = tRot - rot; while (rotDir >= std::numbers::pi) rotDir -= std::numbers::pi * 2; - while (rotDir < -std::numbers::pi ) rotDir += std::numbers::pi * 2; + while (rotDir < -std::numbers::pi) rotDir += std::numbers::pi * 2; rot += rotDir * 0.4f; diff --git a/targets/minecraft/world/level/tile/entity/FurnaceTileEntity.cpp b/targets/minecraft/world/level/tile/entity/FurnaceTileEntity.cpp index d93031521..0540491d8 100644 --- a/targets/minecraft/world/level/tile/entity/FurnaceTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/FurnaceTileEntity.cpp @@ -15,7 +15,8 @@ int furnaceSlotsForDown[] = {FurnaceTileEntity::SLOT_RESULT, FurnaceTileEntity::SLOT_FUEL}; int furnaceSlotsForSides[] = {FurnaceTileEntity::SLOT_FUEL}; -const std::vector FurnaceTileEntity::SLOTS_FOR_UP = std::vector(furnaceSlotsForUp, furnaceSlotsForUp + 1); +const std::vector FurnaceTileEntity::SLOTS_FOR_UP = + std::vector(furnaceSlotsForUp, furnaceSlotsForUp + 1); const std::vector FurnaceTileEntity::SLOTS_FOR_DOWN = std::vector(furnaceSlotsForDown, furnaceSlotsForDown + 2); const std::vector FurnaceTileEntity::SLOTS_FOR_SIDES = @@ -36,7 +37,6 @@ FurnaceTileEntity::FurnaceTileEntity() : TileEntity() { name = L""; } - unsigned int FurnaceTileEntity::getContainerSize() { return items.size(); } std::shared_ptr FurnaceTileEntity::getItem(unsigned int slot) { diff --git a/targets/minecraft/world/level/tile/entity/HopperTileEntity.cpp b/targets/minecraft/world/level/tile/entity/HopperTileEntity.cpp index 35c77a4a6..5e551ca5f 100644 --- a/targets/minecraft/world/level/tile/entity/HopperTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/HopperTileEntity.cpp @@ -348,7 +348,7 @@ std::shared_ptr HopperTileEntity::getSourceContainer( std::shared_ptr HopperTileEntity::getItemAt(Level* level, double xt, double yt, double zt) { AABB item_entity_aabb{xt, yt, zt, xt + 1, yt + 1, zt + 1}; - std::vector >* entities = + std::vector>* entities = level->getEntitiesOfClass(typeid(ItemEntity), &item_entity_aabb, EntitySelector::ENTITY_STILL_ALIVE); @@ -388,7 +388,7 @@ std::shared_ptr HopperTileEntity::getContainerAt(Level* level, if (result == nullptr) { AABB block_above{x, y, z, x + 1, y + 1, z + 1}; - std::vector >* entities = level->getEntities( + std::vector>* entities = level->getEntities( nullptr, &block_above, EntitySelector::CONTAINER_ENTITY_SELECTOR); if ((entities != nullptr) && (entities->size() > 0)) { diff --git a/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp b/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp index 728d1b557..a6a541e01 100644 --- a/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp +++ b/targets/minecraft/world/level/tile/entity/SignTileEntity.cpp @@ -111,8 +111,8 @@ void SignTileEntity::setChanged() { for (int i = 0; i < MAX_SIGN_LINES; ++i) { wcMessages[i]=new wchar_t [MAX_LINE_LENGTH+1]; - memset(wcMessages[i], 0, sizeof(wchar_t)*(MAX_LINE_LENGTH+1)); - if(m_wsmessages[i].length()>0) + memset(wcMessages[i], 0, +sizeof(wchar_t)*(MAX_LINE_LENGTH+1)); if(m_wsmessages[i].length()>0) { memcpy(wcMessages[i],m_wsmessages[i].c_str(),m_wsmessages[i].length()*sizeof(wchar_t)); } @@ -171,8 +171,7 @@ int SignTileEntity::StringVerifyCallback(void* lpParam, // 4J Added std::shared_ptr SignTileEntity::clone() { - std::shared_ptr result = - std::make_shared(); + std::shared_ptr result = std::make_shared(); TileEntity::clone(result); result->m_wsmessages[0] = m_wsmessages[0]; diff --git a/targets/minecraft/world/level/tile/entity/TheEndPortalTile.cpp b/targets/minecraft/world/level/tile/entity/TheEndPortalTile.cpp index f7eef99db..59fb5b970 100644 --- a/targets/minecraft/world/level/tile/entity/TheEndPortalTile.cpp +++ b/targets/minecraft/world/level/tile/entity/TheEndPortalTile.cpp @@ -49,7 +49,8 @@ bool TheEndPortal::shouldRenderFace(LevelSource* level, int x, int y, int z, } void TheEndPortal::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) {} + std::vector* boxes, + std::shared_ptr source) {} bool TheEndPortal::isSolidRender(bool isServerLevel) { return false; } diff --git a/targets/minecraft/world/level/tile/entity/TheEndPortalTile.h b/targets/minecraft/world/level/tile/entity/TheEndPortalTile.h index ce5d8833b..c07594b68 100644 --- a/targets/minecraft/world/level/tile/entity/TheEndPortalTile.h +++ b/targets/minecraft/world/level/tile/entity/TheEndPortalTile.h @@ -24,7 +24,8 @@ public: virtual bool shouldRenderFace(LevelSource* level, int x, int y, int z, int face); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual bool isSolidRender(bool isServerLevel = false); virtual bool isCubeShaped(); virtual int getResourceCount(Random* random); diff --git a/targets/minecraft/world/level/tile/piston/PistonBaseTile.cpp b/targets/minecraft/world/level/tile/piston/PistonBaseTile.cpp index 1733c2384..aac957ba3 100644 --- a/targets/minecraft/world/level/tile/piston/PistonBaseTile.cpp +++ b/targets/minecraft/world/level/tile/piston/PistonBaseTile.cpp @@ -226,7 +226,7 @@ bool PistonBaseTile::triggerEvent(Level* level, int x, int y, int z, int param1, } if (param1 == TRIGGER_EXTEND) { - if (createPush(level, x, y, z, facing)) { + if (createPush(level, x, y, z, facing)) { // 4J - it is (currently) critical that this setData sends data to // the client, so have added a bool to the method so that it sends // data even if the data was already set to the same value as @@ -257,9 +257,9 @@ bool PistonBaseTile::triggerEvent(Level* level, int x, int y, int z, int param1, } else { return false; } - + } else if (param1 == TRIGGER_CONTRACT) { - std::shared_ptr prevTileEntity = level->getTileEntity( + std::shared_ptr prevTileEntity = level->getTileEntity( x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], z + Facing::STEP_Z[facing]); if (prevTileEntity != nullptr && @@ -276,21 +276,17 @@ bool PistonBaseTile::triggerEvent(Level* level, int x, int y, int z, int param1, PistonMovingPiece::newMovingPieceEntity( id, facing, facing, false, true)); - - // sticky movement if (isSticky) { - int twoX = x + Facing::STEP_X[facing] * 2; + int twoX = x + Facing::STEP_X[facing] * 2; int twoY = y + Facing::STEP_Y[facing] * 2; int twoZ = z + Facing::STEP_Z[facing] * 2; int block = level->getTile(twoX, twoY, twoZ); int blockData = level->getData(twoX, twoY, twoZ); bool pistonPiece = false; - - if (block == Tile::pistonMovingPiece_Id) { - // the block two steps away is a moving piston block piece, so + // the block two steps away is a moving piston block piece, so // replace it with the real data, since it's probably this // piston which is changing too fast std::shared_ptr tileEntity = @@ -310,10 +306,9 @@ bool PistonBaseTile::triggerEvent(Level* level, int x, int y, int z, int param1, pistonPiece = true; } } - } - if (!pistonPiece && block > 0 && + if (!pistonPiece && block > 0 && (isPushable(block, level, twoX, twoY, twoZ, false)) && (Tile::tiles[block]->getPistonPushReaction() == Material::PUSH_NORMAL || @@ -345,7 +340,7 @@ bool PistonBaseTile::triggerEvent(Level* level, int x, int y, int z, int param1, z + Facing::STEP_Z[facing]); ignoreUpdate(true); } - + } else { stopSharingIfServer(level, x + Facing::STEP_X[facing], y + Facing::STEP_Y[facing], @@ -403,7 +398,8 @@ void PistonBaseTile::updateShape( void PistonBaseTile::updateDefaultShape() { setShape(0, 0, 0, 1, 1, 1); } void PistonBaseTile::addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source) { + std::vector* boxes, + std::shared_ptr source) { setShape(0, 0, 0, 1, 1, 1); Tile::addAABBs(level, x, y, z, box, boxes, source); } diff --git a/targets/minecraft/world/level/tile/piston/PistonBaseTile.h b/targets/minecraft/world/level/tile/piston/PistonBaseTile.h index 393abe490..96bb7391b 100644 --- a/targets/minecraft/world/level/tile/piston/PistonBaseTile.h +++ b/targets/minecraft/world/level/tile/piston/PistonBaseTile.h @@ -75,7 +75,8 @@ public: TileEntity>()); // 4J added forceData, forceEntity param virtual void updateDefaultShape(); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual std::optional getAABB(Level* level, int x, int y, int z); virtual bool isCubeShaped(); diff --git a/targets/minecraft/world/level/tile/piston/PistonExtensionTile.h b/targets/minecraft/world/level/tile/piston/PistonExtensionTile.h index 903f4fe8d..dfc10381b 100644 --- a/targets/minecraft/world/level/tile/piston/PistonExtensionTile.h +++ b/targets/minecraft/world/level/tile/piston/PistonExtensionTile.h @@ -29,7 +29,8 @@ public: virtual bool mayPlace(Level* level, int x, int y, int z, int face); virtual int getResourceCount(Random* random); virtual void addAABBs(Level* level, int x, int y, int z, AABB* box, - std::vector* boxes, std::shared_ptr source); + std::vector* boxes, + std::shared_ptr source); virtual void updateShape( LevelSource* level, int x, int y, int z, int forceData = -1, std::shared_ptr forceEntity = std::shared_ptr< diff --git a/targets/nbt/include/nbt/ByteArrayTag.h b/targets/nbt/include/nbt/ByteArrayTag.h index 67793e8ff..70a3d4516 100644 --- a/targets/nbt/include/nbt/ByteArrayTag.h +++ b/targets/nbt/include/nbt/ByteArrayTag.h @@ -8,13 +8,13 @@ public: bool m_ownData; ByteArrayTag(const std::wstring& name) : Tag(name) { m_ownData = false; } - ByteArrayTag(const std::wstring& name, std::vector& data, bool ownData = false) + ByteArrayTag(const std::wstring& name, std::vector& data, + bool ownData = false) : Tag(name) { this->data = data; m_ownData = ownData; } // 4J - added ownData param - ~ByteArrayTag() { - } + ~ByteArrayTag() {} void write(DataOutput* dos) { dos->writeInt(data.size()); diff --git a/targets/nbt/include/nbt/CompoundTag.h b/targets/nbt/include/nbt/CompoundTag.h index e9df4f61a..4e8623c7a 100644 --- a/targets/nbt/include/nbt/CompoundTag.h +++ b/targets/nbt/include/nbt/CompoundTag.h @@ -174,7 +174,8 @@ public: CompoundTag* getCompound(const std::wstring& name) { auto it = tags.find(name); if (it == tags.end()) { - auto [it2, inserted] = tags.emplace(name, std::make_unique(name)); + auto [it2, inserted] = + tags.emplace(name, std::make_unique(name)); return static_cast(it2->second.get()); } return static_cast(it->second.get()); @@ -183,7 +184,8 @@ public: ListTag* getList(const std::wstring& name) { auto it = tags.find(name); if (it == tags.end()) { - auto [it2, inserted] = tags.emplace(name, std::make_unique>(name)); + auto [it2, inserted] = + tags.emplace(name, std::make_unique>(name)); return static_cast*>(it2->second.get()); } return static_cast*>(it->second.get()); @@ -191,9 +193,7 @@ public: bool getBoolean(const std::wstring& string) { return getByte(string) != 0; } - void remove(const std::wstring& name) { - tags.erase(name); - } + void remove(const std::wstring& name) { tags.erase(name); } std::wstring toString() { static const int bufSize = 32; diff --git a/targets/nbt/include/nbt/IntArrayTag.h b/targets/nbt/include/nbt/IntArrayTag.h index 540fba711..f90fb295e 100644 --- a/targets/nbt/include/nbt/IntArrayTag.h +++ b/targets/nbt/include/nbt/IntArrayTag.h @@ -7,12 +7,14 @@ class IntArrayTag : public Tag { public: std::vector data; - IntArrayTag(const std::wstring& name) : Tag(name) { data = std::vector(); } - - IntArrayTag(const std::wstring& name, const std::vector& data) : Tag(name) { - this->data = data; + IntArrayTag(const std::wstring& name) : Tag(name) { + data = std::vector(); } + IntArrayTag(const std::wstring& name, const std::vector& data) + : Tag(name) { + this->data = data; + } void write(DataOutput* dos) { dos->writeInt(data.size()); diff --git a/targets/platform/IPlatformInput.h b/targets/platform/IPlatformInput.h index 183e3e326..26827319e 100644 --- a/targets/platform/IPlatformInput.h +++ b/targets/platform/IPlatformInput.h @@ -23,8 +23,8 @@ public: unsigned char ucActionC, unsigned char ucMenuActionC) = 0; virtual void Tick() = 0; - virtual void SetDeadzoneAndMovementRange(unsigned int uiDeadzone, - unsigned int uiMovementRangeMax) = 0; + virtual void SetDeadzoneAndMovementRange( + unsigned int uiDeadzone, unsigned int uiMovementRangeMax) = 0; // Joypad mapping virtual void SetGameJoypadMaps(unsigned char ucMap, unsigned char ucAction, @@ -36,7 +36,8 @@ public: virtual void SetJoypadSensitivity(int iPad, float fSensitivity) = 0; // Input queries - [[nodiscard]] virtual unsigned int GetValue(int iPad, unsigned char ucAction, + [[nodiscard]] virtual unsigned int GetValue(int iPad, + unsigned char ucAction, bool bRepeat = false) = 0; [[nodiscard]] virtual bool ButtonPressed(int iPad, unsigned char ucAction = 255) = 0; @@ -51,9 +52,9 @@ public: virtual void SetJoypadStickTriggerMap(int iPad, unsigned int uiFrom, unsigned int uiTo) = 0; virtual void SetKeyRepeatRate(float fRepeatDelaySecs, - float fRepeatRateSecs) = 0; + float fRepeatRateSecs) = 0; virtual void SetDebugSequence(const char* chSequenceA, int (*Func)(void*), - void* lpParam) = 0; + void* lpParam) = 0; [[nodiscard]] virtual float GetIdleSeconds(int iPad) = 0; [[nodiscard]] virtual bool IsPadConnected(int iPad) = 0; @@ -90,8 +91,9 @@ public: virtual bool VerifyStrings(wchar_t** pwStringA, int iStringC, int (*Func)(void*, STRING_VERIFY_RESPONSE*), void* lpParam) = 0; - virtual void CancelQueuedVerifyStrings( - int (*Func)(void*, STRING_VERIFY_RESPONSE*), void* lpParam) = 0; + virtual void CancelQueuedVerifyStrings(int (*Func)(void*, + STRING_VERIFY_RESPONSE*), + void* lpParam) = 0; virtual void CancelAllVerifyInProgress() = 0; // Mouse diff --git a/targets/platform/IPlatformNetwork.h b/targets/platform/IPlatformNetwork.h index 675a2e0a6..0c94abbac 100644 --- a/targets/platform/IPlatformNetwork.h +++ b/targets/platform/IPlatformNetwork.h @@ -58,7 +58,8 @@ public: // Hosting / joining virtual void HostGame(int localUsersMask, bool bOnlineGame, bool bIsPrivate, - unsigned char publicSlots, unsigned char privateSlots) = 0; + unsigned char publicSlots, + unsigned char privateSlots) = 0; virtual int JoinGame(FriendSessionInfo* searchResult, int dwLocalUsersMask, int dwPrimaryUserIndex) = 0; virtual void CancelJoinGame() {} @@ -68,12 +69,10 @@ public: // Callbacks virtual void RegisterPlayerChangedCallback( - int iPad, - void (*callback)(void*, INetworkPlayer*, bool), + int iPad, void (*callback)(void*, INetworkPlayer*, bool), void* callbackParam) = 0; virtual void UnRegisterPlayerChangedCallback( - int iPad, - void (*callback)(void*, INetworkPlayer*, bool), + int iPad, void (*callback)(void*, INetworkPlayer*, bool), void* callbackParam) = 0; virtual void HandleSignInChange() = 0; diff --git a/targets/platform/IPlatformProfile.h b/targets/platform/IPlatformProfile.h index f12ce9737..0a0e34733 100644 --- a/targets/platform/IPlatformProfile.h +++ b/targets/platform/IPlatformProfile.h @@ -52,7 +52,7 @@ public: [[nodiscard]] virtual bool QuerySigninStatus() = 0; virtual void GetXUID(int iPad, PlayerUID* pXuid, bool bOnlineXuid) = 0; [[nodiscard]] virtual bool AreXUIDSEqual(PlayerUID xuid1, - PlayerUID xuid2) = 0; + PlayerUID xuid2) = 0; [[nodiscard]] virtual bool XUIDIsGuest(PlayerUID xuid) = 0; [[nodiscard]] virtual bool AllowedToPlayMultiplayer(int iProf) = 0; [[nodiscard]] virtual bool GetChatAndContentRestrictions( @@ -64,37 +64,40 @@ public: virtual void SetPrimaryPad(int iPad) = 0; [[nodiscard]] virtual char* GetGamertag(int iPad) = 0; [[nodiscard]] virtual std::wstring GetDisplayName(int iPad) = 0; - virtual void SetSignInChangeCallback( - void (*Func)(void*, bool, unsigned int), void* lpParam) = 0; - virtual void SetNotificationsCallback( - void (*Func)(void*, std::uint32_t, unsigned int), void* lpParam) = 0; + virtual void SetSignInChangeCallback(void (*Func)(void*, bool, + unsigned int), + void* lpParam) = 0; + virtual void SetNotificationsCallback(void (*Func)(void*, std::uint32_t, + unsigned int), + void* lpParam) = 0; [[nodiscard]] virtual bool RegionIsNorthAmerica() = 0; [[nodiscard]] virtual bool LocaleIsUSorCanada() = 0; [[nodiscard]] virtual int GetLiveConnectionStatus() = 0; [[nodiscard]] virtual bool IsSystemUIDisplayed() = 0; virtual void SetProfileReadErrorCallback(void (*Func)(void*), - void* lpParam) = 0; + void* lpParam) = 0; // Profile data - virtual int SetDefaultOptionsCallback( - int (*Func)(void*, PROFILESETTINGS*, const int iPad), - void* lpParam) = 0; - virtual int SetOldProfileVersionCallback( - int (*Func)(void*, unsigned char*, const unsigned short, const int), - void* lpParam) = 0; + virtual int SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*, + const int iPad), + void* lpParam) = 0; + virtual int SetOldProfileVersionCallback(int (*Func)(void*, unsigned char*, + const unsigned short, + const int), + void* lpParam) = 0; [[nodiscard]] virtual PROFILESETTINGS* GetDashboardProfileSettings( int iPad) = 0; virtual void WriteToProfile(int iQuadrant, - bool bGameDefinedDataChanged = false, - bool bOverrideTimeLimit = false) = 0; + bool bGameDefinedDataChanged = false, + bool bOverrideTimeLimit = false) = 0; virtual void ForceQueuedProfileWrites(int iPad = XUSER_INDEX_ANY) = 0; [[nodiscard]] virtual void* GetGameDefinedProfileData(int iQuadrant) = 0; virtual void ResetProfileProcessState() = 0; // Content virtual void AllowedPlayerCreatedContent(int iPad, bool thisQuadrantOnly, - bool* allAllowed, - bool* friendsAllowed) = 0; + bool* allAllowed, + bool* friendsAllowed) = 0; [[nodiscard]] virtual bool CanViewPlayerCreatedContent( int iPad, bool thisQuadrantOnly, PlayerUID* pXuids, unsigned int xuidCount) = 0; @@ -108,27 +111,28 @@ public: // Achievements virtual void RegisterAward(int iAwardNumber, int iGamerconfigID, - EAwardType eType, bool bLeaderboardAffected = false, - CXuiStringTable* pStringTable = nullptr, - int iTitleStr = -1, int iTextStr = -1, - int iAcceptStr = -1, - char* pszThemeName = nullptr, - unsigned int uiThemeSize = 0L) = 0; + EAwardType eType, + bool bLeaderboardAffected = false, + CXuiStringTable* pStringTable = nullptr, + int iTitleStr = -1, int iTextStr = -1, + int iAcceptStr = -1, + char* pszThemeName = nullptr, + unsigned int uiThemeSize = 0L) = 0; [[nodiscard]] virtual int GetAwardId(int iAwardNumber) = 0; [[nodiscard]] virtual EAwardType GetAwardType(int iAwardNumber) = 0; [[nodiscard]] virtual bool CanBeAwarded(int iQuadrant, - int iAwardNumber) = 0; + int iAwardNumber) = 0; virtual void Award(int iQuadrant, int iAwardNumber, - bool bForce = false) = 0; + bool bForce = false) = 0; [[nodiscard]] virtual bool IsAwardsFlagSet(int iQuadrant, int iAward) = 0; // Rich presence virtual void RichPresenceInit(int iPresenceCount, int iContextCount) = 0; virtual void RegisterRichPresenceContext(int iGameConfigContextID) = 0; virtual void SetRichPresenceContextValue(int iPad, int iContextID, - int iVal) = 0; + int iVal) = 0; virtual void SetCurrentGameActivity(int iPad, int iNewPresence, - bool bSetOthersToIdle = false) = 0; + bool bSetOthersToIdle = false) = 0; // Debug virtual void SetDebugFullOverride(bool bVal) = 0; diff --git a/targets/platform/IPlatformRender.h b/targets/platform/IPlatformRender.h index 6cd786e6d..598ca1032 100644 --- a/targets/platform/IPlatformRender.h +++ b/targets/platform/IPlatformRender.h @@ -43,10 +43,7 @@ public: PRIMITIVE_TYPE_COUNT }; - enum eTextureFormat { - TEXTURE_FORMAT_RxGyBzAw, - MAX_TEXTURE_FORMATS - }; + enum eTextureFormat { TEXTURE_FORMAT_RxGyBzAw, MAX_TEXTURE_FORMATS }; virtual ~IPlatformRender() = default; @@ -80,9 +77,9 @@ public: virtual void MatrixRotate(float angle, float x, float y, float z) = 0; virtual void MatrixScale(float x, float y, float z) = 0; virtual void MatrixPerspective(float fovy, float aspect, float zNear, - float zFar) = 0; + float zFar) = 0; virtual void MatrixOrthogonal(float left, float right, float bottom, - float top, float zNear, float zFar) = 0; + float top, float zNear, float zFar) = 0; virtual void MatrixPop() = 0; virtual void MatrixPush() = 0; virtual void MatrixMult(float* mat) = 0; @@ -91,8 +88,8 @@ public: // Draw calls virtual void DrawVertices(ePrimitiveType PrimitiveType, int count, - void* dataIn, eVertexType vType, - ePixelShaderType psType) = 0; + void* dataIn, eVertexType vType, + ePixelShaderType psType) = 0; // Command buffers virtual void CBuffLockStaticCreations() = 0; @@ -114,28 +111,29 @@ public: virtual void TextureBindVertex(int idx, bool scaleLight = false) = 0; virtual void TextureSetTextureLevels(int levels) = 0; [[nodiscard]] virtual int TextureGetTextureLevels() = 0; - virtual void TextureData(int width, int height, void* data, int level, - eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw) = 0; + virtual void TextureData( + int width, int height, void* data, int level, + eTextureFormat format = TEXTURE_FORMAT_RxGyBzAw) = 0; virtual void TextureDataUpdate(int xoffset, int yoffset, int width, - int height, void* data, int level) = 0; + int height, void* data, int level) = 0; virtual void TextureSetParam(int param, int value) = 0; virtual void TextureDynamicUpdateStart() = 0; virtual void TextureDynamicUpdateEnd() = 0; [[nodiscard]] virtual int LoadTextureData(const char* szFilename, - D3DXIMAGE_INFO* pSrcInfo, - int** ppDataOut) = 0; + D3DXIMAGE_INFO* pSrcInfo, + int** ppDataOut) = 0; [[nodiscard]] virtual int LoadTextureData(std::uint8_t* pbData, - std::uint32_t byteCount, - D3DXIMAGE_INFO* pSrcInfo, - int** ppDataOut) = 0; + std::uint32_t byteCount, + D3DXIMAGE_INFO* pSrcInfo, + int** ppDataOut) = 0; [[nodiscard]] virtual int SaveTextureData(const char* szFilename, - D3DXIMAGE_INFO* pSrcInfo, - int* ppDataOut) = 0; + D3DXIMAGE_INFO* pSrcInfo, + int* ppDataOut) = 0; [[nodiscard]] virtual int SaveTextureDataToMemory(void* pOutput, - int outputCapacity, - int* outputLength, - int width, int height, - int* ppDataIn) = 0; + int outputCapacity, + int* outputLength, + int width, int height, + int* ppDataIn) = 0; virtual void ReadPixels(int x, int y, int w, int h, void* buf) = 0; virtual void TextureGetStats() = 0; [[nodiscard]] virtual void* TextureGetTexture(int idx) = 0; @@ -152,7 +150,7 @@ public: virtual void StateSetFaceCullCW(bool enable) = 0; virtual void StateSetLineWidth(float width) = 0; virtual void StateSetWriteEnable(bool red, bool green, bool blue, - bool alpha) = 0; + bool alpha) = 0; virtual void StateSetDepthTestEnable(bool enable) = 0; virtual void StateSetAlphaTestEnable(bool enable) = 0; virtual void StateSetDepthSlopeAndBias(float slope, float bias) = 0; @@ -169,21 +167,21 @@ public: virtual void StateSetLightingEnable(bool enable) = 0; virtual void StateSetVertexTextureUV(float u, float v) = 0; virtual void StateSetLightColour(int light, float red, float green, - float blue) = 0; + float blue) = 0; virtual void StateSetLightAmbientColour(float red, float green, - float blue) = 0; + float blue) = 0; virtual void StateSetLightDirection(int light, float x, float y, - float z) = 0; + float z) = 0; virtual void StateSetLightEnable(int light, bool enable) = 0; // Viewport & clipping virtual void StateSetViewport(eViewportType viewportType) = 0; virtual void StateSetEnableViewportClipPlanes(bool enable) = 0; virtual void StateSetTexGenCol(int col, float x, float y, float z, float w, - bool eyeSpace) = 0; + bool eyeSpace) = 0; virtual void StateSetStencil(int Function, std::uint8_t stencil_ref, - std::uint8_t stencil_func_mask, - std::uint8_t stencil_write_mask) = 0; + std::uint8_t stencil_func_mask, + std::uint8_t stencil_write_mask) = 0; virtual void StateSetForceLOD(int LOD) = 0; virtual void StateSetTextureEnable(bool enable) = 0; virtual void StateSetActiveTexture(int tex) = 0; @@ -201,7 +199,7 @@ public: virtual void DoScreenGrabOnNextPresent() = 0; virtual void CaptureThumbnail(ImageFileBuffer* pngOut) = 0; virtual void CaptureScreen(ImageFileBuffer* jpgOut, - XSOCIAL_PREVIEWIMAGE* previewOut) = 0; + XSOCIAL_PREVIEWIMAGE* previewOut) = 0; // Events virtual void BeginEvent(const wchar_t* eventName) = 0; diff --git a/targets/platform/IPlatformStorage.h b/targets/platform/IPlatformStorage.h index 0c706af04..42d15fce7 100644 --- a/targets/platform/IPlatformStorage.h +++ b/targets/platform/IPlatformStorage.h @@ -118,10 +118,10 @@ public: // Lifecycle virtual void Tick() = 0; virtual void Init(unsigned int uiSaveVersion, - const wchar_t* pwchDefaultSaveName, - char* pszSavePackName, int iMinimumSaveSize, - int (*Func)(void*, const ESavingMessage, int), - void* lpParam, const char* szGroupID) = 0; + const wchar_t* pwchDefaultSaveName, char* pszSavePackName, + int iMinimumSaveSize, + int (*Func)(void*, const ESavingMessage, int), + void* lpParam, const char* szGroupID) = 0; virtual void ResetSaveData() = 0; // Messages @@ -130,15 +130,13 @@ public: unsigned int uiOptionC, unsigned int pad = XUSER_INDEX_ANY, int (*Func)(void*, int, const EMessageResult) = nullptr, void* lpParam = nullptr, C4JStringTable* pStringTable = nullptr, - wchar_t* pwchFormatString = nullptr, - unsigned int focusButton = 0) = 0; + wchar_t* pwchFormatString = nullptr, unsigned int focusButton = 0) = 0; virtual EMessageResult GetMessageBoxResult() = 0; // Save device virtual bool SetSaveDevice(int (*Func)(void*, const bool), void* lpParam, - bool bForceResetOfSaveDevice = false) = 0; - virtual void SetSaveDeviceSelected(unsigned int uiPad, - bool bSelected) = 0; + bool bForceResetOfSaveDevice = false) = 0; + virtual void SetSaveDeviceSelected(unsigned int uiPad, bool bSelected) = 0; virtual bool GetSaveDeviceSelected(unsigned int iPad) = 0; // Save game @@ -149,24 +147,24 @@ public: virtual bool GetSaveUniqueFilename(char* pszName) = 0; virtual void SetSaveUniqueFilename(char* szFilename) = 0; virtual void SetState(ESaveGameControlState eControlState, - int (*Func)(void*, const bool), void* lpParam) = 0; + int (*Func)(void*, const bool), void* lpParam) = 0; virtual void SetSaveDisabled(bool bDisable) = 0; virtual bool GetSaveDisabled() = 0; virtual unsigned int GetSaveSize() = 0; virtual void GetSaveData(void* pvData, unsigned int* puiBytes) = 0; virtual void* AllocateSaveData(unsigned int uiBytes) = 0; virtual void SetSaveImages(std::uint8_t* pbThumbnail, - unsigned int thumbnailBytes, - std::uint8_t* pbImage, unsigned int imageBytes, - std::uint8_t* pbTextData, - unsigned int textDataBytes) = 0; + unsigned int thumbnailBytes, + std::uint8_t* pbImage, unsigned int imageBytes, + std::uint8_t* pbTextData, + unsigned int textDataBytes) = 0; virtual ESaveGameState SaveSaveData(int (*Func)(void*, const bool), - void* lpParam) = 0; - virtual void CopySaveDataToNewSave(std::uint8_t* pbThumbnail, - unsigned int cbThumbnail, - wchar_t* wchNewName, - int (*Func)(void* lpParam, bool), void* lpParam) = 0; + virtual void CopySaveDataToNewSave(std::uint8_t* pbThumbnail, + unsigned int cbThumbnail, + wchar_t* wchNewName, + int (*Func)(void* lpParam, bool), + void* lpParam) = 0; virtual ESaveGameState DoesSaveExist(bool* pbExists) = 0; virtual bool EnoughSpaceForAMinSaveGame() = 0; virtual void SetSaveMessageVPosition(float fY) = 0; @@ -182,39 +180,38 @@ public: unsigned int thumbnailBytes), void* lpParam) = 0; virtual void GetSaveCacheFileInfo(unsigned int fileIndex, - XCONTENT_DATA& xContentData) = 0; + XCONTENT_DATA& xContentData) = 0; virtual void GetSaveCacheFileInfo(unsigned int fileIndex, - std::uint8_t** ppbImageData, - unsigned int* pImageBytes) = 0; - virtual ESaveGameState LoadSaveData( - PSAVE_INFO pSaveInfo, - int (*Func)(void* lpParam, const bool, const bool), - void* lpParam) = 0; - virtual ESaveGameState DeleteSaveData( - PSAVE_INFO pSaveInfo, int (*Func)(void* lpParam, const bool), - void* lpParam) = 0; + std::uint8_t** ppbImageData, + unsigned int* pImageBytes) = 0; + virtual ESaveGameState LoadSaveData(PSAVE_INFO pSaveInfo, + int (*Func)(void* lpParam, const bool, + const bool), + void* lpParam) = 0; + virtual ESaveGameState DeleteSaveData(PSAVE_INFO pSaveInfo, + int (*Func)(void* lpParam, + const bool), + void* lpParam) = 0; // DLC virtual void RegisterMarketplaceCountsCallback( - int (*Func)(void* lpParam, DLC_TMS_DETAILS*, int), - void* lpParam) = 0; + int (*Func)(void* lpParam, DLC_TMS_DETAILS*, int), void* lpParam) = 0; virtual void SetDLCPackageRoot(char* pszDLCRoot) = 0; - virtual EDLCStatus GetDLCOffers( - int iPad, int (*Func)(void*, int, std::uint32_t, int), void* lpParam, - std::uint32_t dwOfferTypesBitmask = - XMARKETPLACE_OFFERING_TYPE_CONTENT) = 0; + virtual EDLCStatus GetDLCOffers(int iPad, + int (*Func)(void*, int, std::uint32_t, int), + void* lpParam, + std::uint32_t dwOfferTypesBitmask = + XMARKETPLACE_OFFERING_TYPE_CONTENT) = 0; virtual unsigned int CancelGetDLCOffers() = 0; virtual void ClearDLCOffers() = 0; virtual XMARKETPLACE_CONTENTOFFER_INFO& GetOffer(unsigned int dw) = 0; virtual int GetOfferCount() = 0; - virtual unsigned int InstallOffer(int iOfferIDC, - std::uint64_t* ullOfferIDA, - int (*Func)(void*, int, int), - void* lpParam, bool bTrial = false) = 0; + virtual unsigned int InstallOffer(int iOfferIDC, std::uint64_t* ullOfferIDA, + int (*Func)(void*, int, int), + void* lpParam, bool bTrial = false) = 0; virtual unsigned int GetAvailableDLCCount(int iPad) = 0; - virtual EDLCStatus GetInstalledDLC(int iPad, - int (*Func)(void*, int, int), - void* lpParam) = 0; + virtual EDLCStatus GetInstalledDLC(int iPad, int (*Func)(void*, int, int), + void* lpParam) = 0; virtual XCONTENT_DATA& GetDLC(unsigned int dw) = 0; virtual std::uint32_t MountInstalledDLC( int iPad, std::uint32_t dwDLC, @@ -222,22 +219,22 @@ public: const char* szMountDrive = nullptr) = 0; virtual unsigned int UnmountInstalledDLC( const char* szMountDrive = nullptr) = 0; - virtual void GetMountedDLCFileList( - const char* szMountDrive, std::vector& fileList) = 0; + virtual void GetMountedDLCFileList(const char* szMountDrive, + std::vector& fileList) = 0; virtual std::string GetMountedPath(std::string szMount) = 0; // Title storage virtual ETMSStatus ReadTMSFile( - int iQuadrant, eGlobalStorage eStorageFacility, - eTMS_FileType eFileType, wchar_t* pwchFilename, - std::uint8_t** ppBuffer, unsigned int* pBufferSize, + int iQuadrant, eGlobalStorage eStorageFacility, eTMS_FileType eFileType, + wchar_t* pwchFilename, std::uint8_t** ppBuffer, + unsigned int* pBufferSize, int (*Func)(void*, wchar_t*, int, bool, int) = nullptr, void* lpParam = nullptr, int iAction = 0) = 0; virtual bool WriteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, - wchar_t* pwchFilename, std::uint8_t* pBuffer, - unsigned int bufferSize) = 0; + wchar_t* pwchFilename, std::uint8_t* pBuffer, + unsigned int bufferSize) = 0; virtual bool DeleteTMSFile(int iQuadrant, eGlobalStorage eStorageFacility, - wchar_t* pwchFilename) = 0; + wchar_t* pwchFilename) = 0; virtual void StoreTMSPathName(wchar_t* pwchName = nullptr) = 0; virtual ETMSStatus TMSPP_ReadFile( int iPad, eGlobalStorage eStorageFacility, @@ -249,11 +246,10 @@ public: virtual int AddSubfile(int regionIndex) = 0; virtual unsigned int GetSubfileCount() = 0; virtual void GetSubfileDetails(unsigned int i, int* regionIndex, - void** data, unsigned int* size) = 0; + void** data, unsigned int* size) = 0; virtual void ResetSubfiles() = 0; virtual void UpdateSubfile(int index, void* data, unsigned int size) = 0; - virtual void SaveSubfiles(int (*Func)(void*, const bool), - void* param) = 0; + virtual void SaveSubfiles(int (*Func)(void*, const bool), void* param) = 0; virtual ESaveGameState GetSaveState() = 0; // Misc diff --git a/targets/platform/PlatformTypes.h b/targets/platform/PlatformTypes.h index 47a0c5fe0..fa946c4e3 100644 --- a/targets/platform/PlatformTypes.h +++ b/targets/platform/PlatformTypes.h @@ -55,7 +55,6 @@ enum class EAwardType { AvatarItem, }; - // Backwards-compatible aliases for call sites still using the old // unscoped names. Remove these as call sites are migrated. inline constexpr auto EKeyboard_Pending = EKeyboardResult::Pending; @@ -67,4 +66,3 @@ inline constexpr auto eAwardType_Achievement = EAwardType::Achievement; inline constexpr auto eAwardType_GamerPic = EAwardType::GamerPic; inline constexpr auto eAwardType_Theme = EAwardType::Theme; inline constexpr auto eAwardType_AvatarItem = EAwardType::AvatarItem; -