format everything
Some checks are pending
Build (Linux, x86-64) / build-linux (push) Waiting to run
Format Check / clang-format (push) Waiting to run

This commit is contained in:
Tropical 2026-04-01 13:48:29 -05:00
parent 3e813592e4
commit dd93cfe91e
380 changed files with 2698 additions and 2595 deletions

View file

@ -660,6 +660,8 @@ void C_4JInput::CancelQueuedVerifyStrings(int (*)(void*,
void C_4JInput::CancelAllVerifyInProgress() {} void C_4JInput::CancelAllVerifyInProgress() {}
// Primary pad (moved from Profile) // Primary pad (moved from Profile)
namespace { int s_inputPrimaryPad = 0; } namespace {
int s_inputPrimaryPad = 0;
}
int C_4JInput::GetPrimaryPad() { return s_inputPrimaryPad; } int C_4JInput::GetPrimaryPad() { return s_inputPrimaryPad; }
void C_4JInput::SetPrimaryPad(int iPad) { s_inputPrimaryPad = iPad; } void C_4JInput::SetPrimaryPad(int iPad) { s_inputPrimaryPad = iPad; }

View file

@ -51,7 +51,6 @@
class C_4JInput : public IPlatformInput { class C_4JInput : public IPlatformInput {
public: public:
void Initialise(int iInputStateC, unsigned char ucMapC, void Initialise(int iInputStateC, unsigned char ucMapC,
unsigned char ucActionC, unsigned char ucMenuActionC); unsigned char ucActionC, unsigned char ucMenuActionC);
void Tick(void); void Tick(void);

View file

@ -158,8 +158,9 @@ std::wstring C_4JProfile::GetDisplayName(int iPad) {
return s_displayNames[p]; return s_displayNames[p];
} }
int C_4JProfile::SetDefaultOptionsCallback( int C_4JProfile::SetDefaultOptionsCallback(int (*Func)(void*, PROFILESETTINGS*,
int (*Func)(void*, PROFILESETTINGS*, const int iPad), void* lpParam) { const int iPad),
void* lpParam) {
s_defaultOptionsCallback = Func; s_defaultOptionsCallback = Func;
s_defaultOptionsCallbackParam = lpParam; s_defaultOptionsCallbackParam = lpParam;
return 0; return 0;

View file

@ -71,17 +71,25 @@ public:
void Tick() {} void Tick() {}
unsigned int RequestSignInUI(bool, bool, bool, bool, bool, unsigned int RequestSignInUI(bool, bool, bool, bool, bool,
int (*)(void*, const bool, const int), int (*)(void*, const bool, const int), void*,
void*, int = XUSER_INDEX_ANY) { return 0; } int = XUSER_INDEX_ANY) {
return 0;
}
unsigned int DisplayOfflineProfile(int (*)(void*, const bool, const int), unsigned int DisplayOfflineProfile(int (*)(void*, const bool, const int),
void*, int = XUSER_INDEX_ANY) { return 0; } void*, int = XUSER_INDEX_ANY) {
unsigned int RequestConvertOfflineToGuestUI( return 0;
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 SetPrimaryPlayerChanged(bool) {} void SetPrimaryPlayerChanged(bool) {}
void ShowProfileCard(int, PlayerUID) {} void ShowProfileCard(int, PlayerUID) {}
bool GetProfileAvatar(int, int (*)(void*, std::uint8_t*, unsigned int), bool GetProfileAvatar(int, int (*)(void*, std::uint8_t*, unsigned int),
void*) { return false; } void*) {
return false;
}
void CancelProfileAvatarRequest() {} void CancelProfileAvatarRequest() {}
void SetSignInChangeCallback(void (*)(void*, bool, unsigned int), void*) {} void SetSignInChangeCallback(void (*)(void*, bool, unsigned int), void*) {}
void SetNotificationsCallback(void (*)(void*, std::uint32_t, unsigned int), void SetNotificationsCallback(void (*)(void*, std::uint32_t, unsigned int),
@ -93,13 +101,15 @@ public:
void SetProfileReadErrorCallback(void (*)(void*), void*) {} void SetProfileReadErrorCallback(void (*)(void*), void*) {}
int SetOldProfileVersionCallback(int (*)(void*, unsigned char*, int SetOldProfileVersionCallback(int (*)(void*, unsigned char*,
const unsigned short, const int), const unsigned short, const int),
void*) { return 0; } void*) {
return 0;
}
void WriteToProfile(int, bool = false, bool = false) {} void WriteToProfile(int, bool = false, bool = false) {}
void ForceQueuedProfileWrites(int = XUSER_INDEX_ANY) {} void ForceQueuedProfileWrites(int = XUSER_INDEX_ANY) {}
void ResetProfileProcessState() {} void ResetProfileProcessState() {}
void RegisterAward(int, int, EAwardType, bool = false, void RegisterAward(int, int, EAwardType, bool = false,
CXuiStringTable* = nullptr, int = -1, int = -1, CXuiStringTable* = nullptr, int = -1, int = -1, int = -1,
int = -1, char* = nullptr, unsigned int = 0L) {} char* = nullptr, unsigned int = 0L) {}
int GetAwardId(int) { return 0; } int GetAwardId(int) { return 0; }
EAwardType GetAwardType(int) { return eAwardType_Achievement; } EAwardType GetAwardType(int) { return eAwardType_Achievement; }
bool CanBeAwarded(int, int) { return false; } bool CanBeAwarded(int, int) { return false; }

View file

@ -66,7 +66,6 @@
#include <thread> #include <thread>
#include <chrono> #include <chrono>
// CMinecraftApp app; // CMinecraftApp app;
unsigned int CMinecraftApp::m_uiLastSignInData = 0; unsigned int CMinecraftApp::m_uiLastSignInData = 0;
@ -147,7 +146,7 @@ CMinecraftApp::CMinecraftApp() {
m_xuidNotch = INVALID_XUID; 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_XUIDS_XML=false;
// m_bRead_TMS_DLCINFO_XML=false; // m_bRead_TMS_DLCINFO_XML=false;
@ -164,7 +163,7 @@ CMinecraftApp::CMinecraftApp() {
m_iTotalDLCInstalled = 0; m_iTotalDLCInstalled = 0;
mfTrialPausedTime = 0.0f; mfTrialPausedTime = 0.0f;
m_uiAutosaveTimer = 0; m_uiAutosaveTimer = 0;
memset(m_pszUniqueMapName, 0, 14); memset(m_pszUniqueMapName, 0, 14);
m_bNewDLCAvailable = false; m_bNewDLCAvailable = false;
m_bSeenNewDLCTip = false; m_bSeenNewDLCTip = false;
@ -177,7 +176,7 @@ CMinecraftApp::CMinecraftApp() {
m_GameNewHellScale = 0; m_GameNewHellScale = 0;
#endif #endif
memset(m_playerColours, 0, MINECRAFT_NET_MAX_PLAYERS); memset(m_playerColours, 0, MINECRAFT_NET_MAX_PLAYERS);
m_iDLCOfferC = 0; m_iDLCOfferC = 0;
m_bAllDLCContentRetrieved = true; m_bAllDLCContentRetrieved = true;
@ -2212,8 +2211,10 @@ void CMinecraftApp::HandleXuiActions(void) {
// CSocialManager::Instance() // CSocialManager::Instance()
// ->AreAllUsersAllowedToPostImages()) { // ->AreAllUsersAllowedToPostImages()) {
// // disable character name tags for the shot // // disable character name tags for the shot
// // m_bwasHidingGui = pMinecraft->options->hideGui; // // m_bwasHidingGui =
// // // 4J Stu - Removed 1.8.2 bug fix (TU6) as don't // pMinecraft->options->hideGui;
// // // 4J Stu - Removed 1.8.2 bug fix (TU6) as
// don't
// // need this // // need this
// pMinecraft->options->hideGui = true; // pMinecraft->options->hideGui = true;
@ -2577,8 +2578,7 @@ void CMinecraftApp::HandleXuiActions(void) {
return; return;
} }
// flag to capture the save thumbnail // flag to capture the save thumbnail
SetAction(i, eAppAction_ExitWorldCapturedThumbnail, SetAction(i, eAppAction_ExitWorldCapturedThumbnail, param);
param);
// Change the presence info // Change the presence info
// Are we offline or online, and how many players are there // Are we offline or online, and how many players are there
@ -2878,7 +2878,8 @@ void CMinecraftApp::HandleXuiActions(void) {
bool gameStarted = false; bool gameStarted = false;
for (int j = 0; j < pMinecraft->levels.size(); for (int j = 0; j < pMinecraft->levels.size();
j++) { j++) {
if (pMinecraft->levels.data()[j] != nullptr) { if (pMinecraft->levels.data()[j] !=
nullptr) {
gameStarted = true; gameStarted = true;
break; break;
} }
@ -3078,9 +3079,8 @@ void CMinecraftApp::HandleXuiActions(void) {
uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestAlertMessage( ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, IDS_EXIT_GAME, IDS_CONFIRM_LEAVE_VIA_INVITE, uiIDA,
uiIDA, 2, i, 2, i, &CMinecraftApp::ExitAndJoinFromInvite, this);
&CMinecraftApp::ExitAndJoinFromInvite, this);
} }
} break; } break;
case eAppAction_ExitAndJoinFromInviteConfirmed: { case eAppAction_ExitAndJoinFromInviteConfirmed: {
@ -3381,7 +3381,6 @@ void CMinecraftApp::HandleXuiActions(void) {
// can't ban the level at that point // can't ban the level at that point
if (g_NetworkManager.IsInGameplay() && if (g_NetworkManager.IsInGameplay() &&
!g_NetworkManager.IsLeavingGame()) { !g_NetworkManager.IsLeavingGame()) {
// primary player would exit the world, secondary would // primary player would exit the world, secondary would
// exit the player // exit the player
if (ProfileManager.GetPrimaryPad() == i) { if (ProfileManager.GetPrimaryPad() == i) {
@ -3636,7 +3635,8 @@ void CMinecraftApp::loadStringTable() {
} }
std::wstring localisationFile = L"languages.loc"; std::wstring localisationFile = L"languages.loc";
if (m_mediaArchive->hasFile(localisationFile)) { if (m_mediaArchive->hasFile(localisationFile)) {
std::vector<uint8_t> locFile = m_mediaArchive->getFile(localisationFile); std::vector<uint8_t> locFile =
m_mediaArchive->getFile(localisationFile);
m_stringTable = new StringTable(locFile.data(), locFile.size()); m_stringTable = new StringTable(locFile.data(), locFile.size());
} else { } else {
m_stringTable = nullptr; m_stringTable = nullptr;
@ -4369,8 +4369,7 @@ void CMinecraftApp::UpdateTime() {
m_Time.qwAppTime += qwDeltaTime; m_Time.qwAppTime += qwDeltaTime;
m_Time.qwTime = qwNewTime; m_Time.qwTime = qwNewTime;
m_Time.fElapsedTime = m_Time.fElapsedTime = m_Time.fSecsPerTick * static_cast<float>(qwDeltaTime);
m_Time.fSecsPerTick * static_cast<float>(qwDeltaTime);
m_Time.fAppTime = m_Time.fAppTime =
m_Time.fSecsPerTick * static_cast<float>(m_Time.qwAppTime); m_Time.fSecsPerTick * static_cast<float>(m_Time.qwAppTime);
} }
@ -4816,7 +4815,7 @@ int CMinecraftApp::TipsSortFunction(const void* a, const void* b) {
void CMinecraftApp::InitialiseTips() { void CMinecraftApp::InitialiseTips() {
// We'll randomise the tips at start up based on their priority // 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 // Make the first tip tell you that you can play splitscreen in HD modes if
// you are in SD // you are in SD
@ -4873,8 +4872,7 @@ void CMinecraftApp::InitialiseTips() {
int CMinecraftApp::GetNextTip() { int CMinecraftApp::GetNextTip() {
static bool bShowSkinDLCTip = true; static bool bShowSkinDLCTip = true;
if (app.GetNewDLCAvailable() && if (app.GetNewDLCAvailable() && app.DisplayNewDLCTip()) {
app.DisplayNewDLCTip()) {
return IDS_TIPS_GAMETIP_NEWDLC; return IDS_TIPS_GAMETIP_NEWDLC;
} else { } else {
if (bShowSkinDLCTip) { if (bShowSkinDLCTip) {
@ -5261,7 +5259,7 @@ int32_t CMinecraftApp::RegisterMojangData(wchar_t* pXuidName, PlayerUID xuid,
if (eTempXuid != eXUID_Undefined) { if (eTempXuid != eXUID_Undefined) {
pMojangData = new MOJANG_DATA; pMojangData = new MOJANG_DATA;
memset(pMojangData, 0, sizeof(MOJANG_DATA)); memset(pMojangData, 0, sizeof(MOJANG_DATA));
pMojangData->eXuid = eTempXuid; pMojangData->eXuid = eTempXuid;
wcsncpy(pMojangData->wchSkin, pSkin, MAX_CAPENAME_SIZE); wcsncpy(pMojangData->wchSkin, pSkin, MAX_CAPENAME_SIZE);
@ -5313,7 +5311,7 @@ int32_t CMinecraftApp::RegisterDLCData(wchar_t* pType, wchar_t* pBannerName,
wchar_t* pDataFile) { wchar_t* pDataFile) {
int32_t hr = 0; int32_t hr = 0;
DLC_INFO* pDLCData = new DLC_INFO; 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_Full = ullOfferID_Full;
pDLCData->ullOfferID_Trial = ullOfferID_Trial; pDLCData->ullOfferID_Trial = ullOfferID_Trial;
pDLCData->eDLCType = e_DLC_NotDefined; pDLCData->eDLCType = e_DLC_NotDefined;
@ -5375,7 +5373,7 @@ int32_t CMinecraftApp::RegisterDLCData(char* pchDLCName,
char chDLCType[3]; char chDLCType[3];
int32_t hr = 0; int32_t hr = 0;
DLC_INFO* pDLCData = new DLC_INFO; DLC_INFO* pDLCData = new DLC_INFO;
memset(pDLCData, 0, sizeof(DLC_INFO)); memset(pDLCData, 0, sizeof(DLC_INFO));
chDLCType[0] = pchDLCName[0]; chDLCType[0] = pchDLCName[0];
chDLCType[1] = pchDLCName[1]; chDLCType[1] = pchDLCName[1];
@ -5702,7 +5700,6 @@ void CMinecraftApp::RemoveLevelFromBannedLevelList(int iPad, PlayerUID xuid,
if (pBannedListData != nullptr) { if (pBannedListData != nullptr) {
if (IsEqualXUID(pBannedListData->xuid, xuid) && if (IsEqualXUID(pBannedListData->xuid, xuid) &&
(strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) { (strcmp(pBannedListData->pszLevelName, pszLevelName) == 0)) {
// match found, so remove this entry // match found, so remove this entry
it = m_vBannedListA[iPad]->erase(it); it = m_vBannedListA[iPad]->erase(it);
} else { } else {
@ -6203,7 +6200,7 @@ void CMinecraftApp::GetImageTextData(std::uint8_t* imageData,
// check that it's the 4J text // check that it's the 4J text
unsigned char* pszKeyword = &ucPtr[uiCount]; unsigned char* pszKeyword = &ucPtr[uiCount];
while (pszKeyword < ucPtr + uiCount + uiChunkLen) { while (pszKeyword < ucPtr + uiCount + uiChunkLen) {
memset(szKeyword, 0, 80); memset(szKeyword, 0, 80);
unsigned int uiKeywordC = 0; unsigned int uiKeywordC = 0;
while (*pszKeyword != 0) { while (*pszKeyword != 0) {
szKeyword[uiKeywordC++] = *pszKeyword; szKeyword[uiKeywordC++] = *pszKeyword;
@ -6225,7 +6222,7 @@ void CMinecraftApp::GetImageTextData(std::uint8_t* imageData,
unsigned int uiValueC = 0; unsigned int uiValueC = 0;
unsigned char pszHostOptions[9]; // Hex representation of unsigned char pszHostOptions[9]; // Hex representation of
// unsigned int // unsigned int
memset(&pszHostOptions, 0, 9); memset(&pszHostOptions, 0, 9);
while (*pszKeyword != 0 && while (*pszKeyword != 0 &&
(pszKeyword < ucPtr + uiCount + uiChunkLen) && (pszKeyword < ucPtr + uiCount + uiChunkLen) &&
uiValueC < 8) { uiValueC < 8) {
@ -6242,7 +6239,7 @@ void CMinecraftApp::GetImageTextData(std::uint8_t* imageData,
unsigned int uiValueC = 0; unsigned int uiValueC = 0;
unsigned char pszTexturePack[9]; // Hex representation of unsigned char pszTexturePack[9]; // Hex representation of
// unsigned int // unsigned int
memset(&pszTexturePack, 0, 9); memset(&pszTexturePack, 0, 9);
while (*pszKeyword != 0 && while (*pszKeyword != 0 &&
(pszKeyword < ucPtr + uiCount + uiChunkLen) && (pszKeyword < ucPtr + uiCount + uiChunkLen) &&
uiValueC < 8) { uiValueC < 8) {
@ -6653,7 +6650,7 @@ unsigned int CMinecraftApp::AddTMSPPFileTypeRequest(eDLCContentType eType,
// app.DebugPrintf("Adding a request to the TMSPP // app.DebugPrintf("Adding a request to the TMSPP
// download queue - %ls\n",pDLC->wchBanner); // download queue - %ls\n",pDLC->wchBanner);
TMSPPRequest* pTMSPPreq = new TMSPPRequest; TMSPPRequest* pTMSPPreq = new TMSPPRequest;
memset(pTMSPPreq, 0, sizeof(TMSPPRequest)); memset(pTMSPPreq, 0, sizeof(TMSPPRequest));
pTMSPPreq->CallbackFunc = pTMSPPreq->CallbackFunc =
&CMinecraftApp::TMSPPFileReturned; &CMinecraftApp::TMSPPFileReturned;
@ -7115,7 +7112,8 @@ bool CMinecraftApp::hasArchiveFile(const std::wstring& filename) {
return m_mediaArchive->hasFile(filename); return m_mediaArchive->hasFile(filename);
} }
std::vector<uint8_t> CMinecraftApp::getArchiveFile(const std::wstring& filename) { std::vector<uint8_t> CMinecraftApp::getArchiveFile(
const std::wstring& filename) {
TexturePack* tPack = nullptr; TexturePack* tPack = nullptr;
Minecraft* pMinecraft = Minecraft::GetInstance(); Minecraft* pMinecraft = Minecraft::GetInstance();
if (pMinecraft && pMinecraft->skins) if (pMinecraft && pMinecraft->skins)

View file

@ -491,8 +491,8 @@ public:
bool m_bChangingSessionType; bool m_bChangingSessionType;
bool m_bReallyChangingSessionType; bool m_bReallyChangingSessionType;
// trial, and trying to unlock full // trial, and trying to unlock full
// version on an upsell // version on an upsell
void loadMediaArchive(); void loadMediaArchive();
void loadStringTable(); void loadStringTable();

View file

@ -184,8 +184,9 @@ void SoundEngine::play(int iSound, float x, float y, float z, float volume,
if (szId[i] == '.') szId[i] = '/'; if (szId[i] == '.') szId[i] = '/';
std::string base = PathHelper::GetExecutableDirA() + "/"; std::string base = PathHelper::GetExecutableDirA() + "/";
const char* roots[] = {"Sound/Minecraft/", "Minecraft.Client/Common/Sound/Minecraft/", const char* roots[] = {
"Minecraft.Client/Common/res/TitleUpdate/res/Sound/Minecraft/"}; "Sound/Minecraft/", "Minecraft.Client/Common/Sound/Minecraft/",
"Minecraft.Client/Common/res/TitleUpdate/res/Sound/Minecraft/"};
char finalPath[512] = {0}; char finalPath[512] = {0};
bool found = false; bool found = false;
@ -457,7 +458,8 @@ void SoundEngine::playMusicTick() {
bool found = false; bool found = false;
m_szStreamName[0] = '\0'; 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* r : roots) {
for (const char* e : {".ogg", ".mp3", ".wav"}) { for (const char* e : {".ogg", ".mp3", ".wav"}) {
@ -1135,8 +1137,10 @@ void SoundEngine::tick(std::shared_ptr<Mob>* players, float a) {
float yRot = players[i]->yRotO + float yRot = players[i]->yRotO +
(players[i]->yRot - players[i]->yRotO) * a; (players[i]->yRot - players[i]->yRotO) * a;
float yCos = (float)cos(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); float yCos =
float ySin = (float)sin(-yRot * Mth::DEG_TO_RAD - std::numbers::pi); (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 // store the listener positions for splitscreen
m_ListenerA[i].vPosition.x = x; m_ListenerA[i].vPosition.x = x;

View file

@ -347,7 +347,7 @@ ColourTable::ColourTable(ColourTable* defaultColours, std::uint8_t* pbData,
std::uint32_t dataLength) { std::uint32_t dataLength) {
// 4J Stu - Default the colours that of the table passed in // 4J Stu - Default the colours that of the table passed in
memcpy((void*)m_colourValues, (void*)defaultColours->m_colourValues, memcpy((void*)m_colourValues, (void*)defaultColours->m_colourValues,
sizeof(int) * eMinecraftColour_COUNT); sizeof(int) * eMinecraftColour_COUNT);
loadColoursFromData(pbData, dataLength); loadColoursFromData(pbData, dataLength);
} }
void ColourTable::loadColoursFromData(std::uint8_t* pbData, void ColourTable::loadColoursFromData(std::uint8_t* pbData,

View file

@ -109,12 +109,11 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
case DLCManager::e_DLCParamType_Box: { case DLCManager::e_DLCParamType_Box: {
wchar_t wchBodyPart[10]; wchar_t wchBodyPart[10];
SKIN_BOX* pSkinBox = new SKIN_BOX; 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, swscanf(value.c_str(), L"%9ls%f%f%f%f%f%f%f%f", wchBodyPart, 10,
&pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fX, &pSkinBox->fY, &pSkinBox->fZ, &pSkinBox->fW,
&pSkinBox->fW, &pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fH, &pSkinBox->fD, &pSkinBox->fU, &pSkinBox->fV);
&pSkinBox->fU, &pSkinBox->fV);
if (wcscmp(wchBodyPart, L"HEAD") == 0) { if (wcscmp(wchBodyPart, L"HEAD") == 0) {
pSkinBox->ePart = eBodyPart_Head; pSkinBox->ePart = eBodyPart_Head;
@ -135,7 +134,7 @@ void DLCSkinFile::addParameter(DLCManager::EDLCParameterType type,
} break; } break;
case DLCManager::e_DLCParamType_Anim: { case DLCManager::e_DLCParamType_Anim: {
swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask, swscanf(value.c_str(), L"%X", &m_uiAnimOverrideBitmask,
sizeof(unsigned int)); sizeof(unsigned int));
uint32_t skinId = app.getSkinIdFromPath(m_path); uint32_t skinId = app.getSkinIdFromPath(m_path);
app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask); app.SetAnimOverrideBitmask(skinId, m_uiAnimOverrideBitmask);
break; break;

View file

@ -199,7 +199,6 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn,
dis.close(); dis.close();
bais.close(); bais.close();
ByteArrayInputStream bais2(content); ByteArrayInputStream bais2(content);
DataInputStream dis2(&bais2); DataInputStream dis2(&bais2);
@ -228,7 +227,6 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions* lgo, uint8_t* dIn,
delete lgo; delete lgo;
} }
// Close and return. // Close and return.
dis2.close(); dis2.close();
bais2.close(); bais2.close();
@ -286,8 +284,8 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* dSize) {
// Write string table. // Write string table.
uint8_t* stbaPtr = nullptr; uint8_t* stbaPtr = nullptr;
unsigned int stbaSize = 0; unsigned int stbaSize = 0;
m_currentGameRuleDefinitions->getStringTable()->getData( m_currentGameRuleDefinitions->getStringTable()->getData(&stbaPtr,
&stbaPtr, &stbaSize); &stbaSize);
std::vector<uint8_t> stba(stbaPtr, stbaPtr + stbaSize); std::vector<uint8_t> stba(stbaPtr, stbaPtr + stbaSize);
compr_dos.writeInt(stba.size()); compr_dos.writeInt(stba.size());
compr_dos.write(stba); compr_dos.write(stba);
@ -313,7 +311,6 @@ void GameRuleManager::saveGameRules(uint8_t** dOut, unsigned int* dSize) {
dos.writeInt(compr_baos.buf.size()); dos.writeInt(compr_baos.buf.size());
dos.write(compr_ba); dos.write(compr_ba);
compr_dos.close(); compr_dos.close();
compr_baos.close(); compr_baos.close();
// -- END COMPRESSED -- // // -- END COMPRESSED -- //
@ -416,7 +413,8 @@ bool GameRuleManager::readRuleFile(
std::vector<uint8_t> compressedBuffer(compressedSize); std::vector<uint8_t> compressedBuffer(compressedSize);
dis.read(compressedBuffer); dis.read(compressedBuffer);
std::vector<uint8_t> decompressedBuffer = std::vector<uint8_t>(uncompressedSize); std::vector<uint8_t> decompressedBuffer =
std::vector<uint8_t>(uncompressedSize);
unsigned int decompressedSize = uncompressedSize; unsigned int decompressedSize = uncompressedSize;
switch (compressionType) { switch (compressionType) {
@ -467,7 +465,6 @@ bool GameRuleManager::readRuleFile(
*/ */
}; };
contentBais = new ByteArrayInputStream(decompressedBuffer); contentBais = new ByteArrayInputStream(decompressedBuffer);
contentDis = new DataInputStream(contentBais); contentDis = new DataInputStream(contentBais);
} }

View file

@ -166,7 +166,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
if (m_completed) return; if (m_completed) return;
if (chunk->level->dimension->id != m_dimension) return; if (chunk->level->dimension->id != m_dimension) return;
if (m_schematic == nullptr) if (m_schematic == nullptr)
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
if (!m_locationBox.has_value()) updateLocationBox(); if (!m_locationBox.has_value()) updateLocationBox();
@ -178,15 +178,13 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n", app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n",
m_schematicName.c_str(), chunk->x, chunk->z); m_schematicName.c_str(), chunk->x, chunk->z);
#endif #endif
m_totalBlocksChanged += m_schematic->applyBlocksAndData( m_totalBlocksChanged += m_schematic->applyBlocksAndData(
chunk, chunkBox, &*m_locationBox, m_rotation); chunk, chunkBox, &*m_locationBox, m_rotation);
// Add the tileEntities // Add the tileEntities
m_schematic->applyTileEntities(chunk, chunkBox, &*m_locationBox, m_schematic->applyTileEntities(chunk, chunkBox, &*m_locationBox,
m_rotation); m_rotation);
// TODO This does not take into account things that go outside the // TODO This does not take into account things that go outside the
// bounds of the world // bounds of the world
int targetBlocks = (m_locationBox->x1 - m_locationBox->x0) * int targetBlocks = (m_locationBox->x1 - m_locationBox->x0) *
@ -199,7 +197,6 @@ void ApplySchematicRuleDefinition::processSchematic(AABB* chunkBox,
// m_schematic = nullptr; // m_schematic = nullptr;
} }
} }
} }
void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox, void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
@ -207,7 +204,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
if (m_completed) return; if (m_completed) return;
if (chunk->level->dimension->id != m_dimension) return; if (chunk->level->dimension->id != m_dimension) return;
if (m_schematic == nullptr) if (m_schematic == nullptr)
m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName); m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
if (!m_locationBox.has_value()) updateLocationBox(); if (!m_locationBox.has_value()) updateLocationBox();
@ -219,10 +216,9 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n", app.DebugPrintf("Applying schematic %ls to chunk (%d,%d)\n",
m_schematicName.c_str(), chunk->x, chunk->z); m_schematicName.c_str(), chunk->x, chunk->z);
#endif #endif
m_totalBlocksChangedLighting += m_schematic->applyLighting( m_totalBlocksChangedLighting += m_schematic->applyLighting(
chunk, chunkBox, &*m_locationBox, m_rotation); chunk, chunkBox, &*m_locationBox, m_rotation);
// TODO This does not take into account things that go outside the // TODO This does not take into account things that go outside the
// bounds of the world // bounds of the world
int targetBlocks = (m_locationBox->x1 - m_locationBox->x0) * int targetBlocks = (m_locationBox->x1 - m_locationBox->x0) *
@ -235,7 +231,6 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB* chunkBox,
// m_schematic = nullptr; // m_schematic = nullptr;
} }
} }
} }
bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0, bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0,

View file

@ -62,7 +62,6 @@ void ConsoleSchematicFile::save(DataOutputStream* dos) {
dos->write(ba); dos->write(ba);
save_tags(dos); save_tags(dos);
} }
} }
@ -126,7 +125,6 @@ void ConsoleSchematicFile::load(DataInputStream* dis) {
Compression::getCompression()->SetDecompressionType( Compression::getCompression()->SetDecompressionType(
APPROPRIATE_COMPRESSION_TYPE); APPROPRIATE_COMPRESSION_TYPE);
}; };
} }
// READ TAGS // // READ TAGS //
@ -228,12 +226,13 @@ int64_t ConsoleSchematicFile::applyBlocksAndData(LevelChunk* chunk,
int rowBlockCount = getYSize() * getZSize(); int rowBlockCount = getYSize() * getZSize();
int totalBlockCount = getXSize() * rowBlockCount; int totalBlockCount = getXSize() * rowBlockCount;
std::vector<uint8_t> blockData = std::vector<uint8_t>(Level::CHUNK_TILE_COUNT); std::vector<uint8_t> blockData =
chunk->getBlockData(blockData); std::vector<uint8_t>(Level::CHUNK_TILE_COUNT);
chunk->getBlockData(blockData);
std::vector<uint8_t> dataData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getDataData(dataData);
std::vector<uint8_t> dataData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getDataData(dataData);
// Ignore light data // Ignore light data
int blockLightP = -1; int blockLightP = -1;
@ -305,11 +304,10 @@ int64_t ConsoleSchematicFile::applyBlocksAndData(LevelChunk* chunk,
// } // }
//} //}
chunk->setBlockData(blockData); chunk->setBlockData(blockData);
chunk->recalcHeightmapOnly(); chunk->recalcHeightmapOnly();
chunk->setDataData(dataData); chunk->setDataData(dataData);
// A basic pass through to roughly do the lighting. At this point of // 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 // post-processing, we don't have all the neighbouring chunks loaded in, so
@ -637,8 +635,8 @@ void ConsoleSchematicFile::generateSchematicFile(
// Write zSize // Write zSize
if (dos != nullptr) dos->writeInt(zSize); if (dos != nullptr) dos->writeInt(zSize);
// std::vector<uint8_t> rawBuffer = level->getBlocksAndData(xStart, yStart, zStart, // std::vector<uint8_t> rawBuffer = level->getBlocksAndData(xStart, yStart,
// xSize, ySize, zSize, false); // zStart, xSize, ySize, zSize, false);
int xRowSize = ySize * zSize; int xRowSize = ySize * zSize;
int blockCount = xSize * xRowSize; int blockCount = xSize * xRowSize;
std::vector<uint8_t> result(blockCount * 3 / 2); std::vector<uint8_t> result(blockCount * 3 / 2);
@ -701,7 +699,8 @@ void ConsoleSchematicFile::generateSchematicFile(
break; break;
}; };
std::vector<uint8_t> buffer = std::vector<uint8_t>(ucTemp, ucTemp + inputSize); std::vector<uint8_t> buffer =
std::vector<uint8_t>(ucTemp, ucTemp + inputSize);
delete[] ucTemp; delete[] ucTemp;
if (dos != nullptr) dos->writeInt(inputSize); if (dos != nullptr) dos->writeInt(inputSize);
@ -794,11 +793,11 @@ void ConsoleSchematicFile::generateSchematicFile(
if (dos != nullptr) NbtIo::write(&tag, dos); if (dos != nullptr) NbtIo::write(&tag, dos);
} }
void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8_t>* data, void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk,
int x0, int y0, int z0, int x1, std::vector<uint8_t>* data, int x0,
int y1, int z1, int& blocksP, int y0, int z0, int x1, int y1,
int& dataP, int& blockLightP, int z1, int& blocksP, int& dataP,
int& skyLightP) { int& blockLightP, int& skyLightP) {
// 4J Stu - Needs updated to work with higher worlds, should still work with // 4J Stu - Needs updated to work with higher worlds, should still work with
// non-optimised version below // non-optimised version below
// int xs = x1 - x0; // int xs = x1 - x0;
@ -806,22 +805,23 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
// int zs = z1 - z0; // int zs = z1 - z0;
// if (xs * ys * zs == LevelChunk::BLOCKS_LENGTH) // if (xs * ys * zs == LevelChunk::BLOCKS_LENGTH)
//{ //{
// std::vector<uint8_t> blockData = std::vector<uint8_t>(data->data + blocksP, // std::vector<uint8_t> blockData = std::vector<uint8_t>(data->data +
// blocksP,
// Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData); // Level::CHUNK_TILE_COUNT); chunk->getBlockData(blockData);
// blocksP += blockData.size(); // blocksP += blockData.size();
// std::vector<uint8_t> dataData = std::vector<uint8_t>(data->data + dataP, 16384); // std::vector<uint8_t> dataData = std::vector<uint8_t>(data->data + dataP,
// chunk->getBlockLightData(dataData); // 16384); chunk->getBlockLightData(dataData); dataP +=
// dataP += dataData.size(); // dataData.size();
// std::vector<uint8_t> blockLightData = std::vector<uint8_t>(data->data + blockLightP, 16384); // std::vector<uint8_t> blockLightData = std::vector<uint8_t>(data->data +
// chunk->getBlockLightData(blockLightData); // blockLightP, 16384); chunk->getBlockLightData(blockLightData);
// blockLightP += blockLightData.size(); // blockLightP
//+= blockLightData.size();
// std::vector<uint8_t> skyLightData = std::vector<uint8_t>(data->data + skyLightP, 16384); // std::vector<uint8_t> skyLightData = std::vector<uint8_t>(data->data +
// chunk->getSkyLightData(skyLightData); // skyLightP, 16384); chunk->getSkyLightData(skyLightData); skyLightP
// skyLightP += skyLightData.size(); // += skyLightData.size(); return;
// return;
//} //}
bool bHasLower, bHasUpper; bool bHasLower, bHasUpper;
@ -843,7 +843,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
bHasUpper = true; bHasUpper = true;
} }
std::vector<uint8_t> blockData = std::vector<uint8_t>(Level::CHUNK_TILE_COUNT); std::vector<uint8_t> blockData =
std::vector<uint8_t>(Level::CHUNK_TILE_COUNT);
chunk->getBlockData(blockData); chunk->getBlockData(blockData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -851,7 +852,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
int slot = x << Level::genDepthBitsPlusFour | int slot = x << Level::genDepthBitsPlusFour |
z << Level::genDepthBits | lowerY0; z << Level::genDepthBits | lowerY0;
int len = lowerY1 - lowerY0; int len = lowerY1 - lowerY0;
std::copy(blockData.data() + slot, blockData.data() + slot + len, data->data() + blocksP); std::copy(blockData.data() + slot,
blockData.data() + slot + len,
data->data() + blocksP);
blocksP += len; blocksP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -859,12 +862,15 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
z << Level::genDepthBits | upperY0) + z << Level::genDepthBits | upperY0) +
Level::COMPRESSED_CHUNK_SECTION_TILES; Level::COMPRESSED_CHUNK_SECTION_TILES;
int len = upperY1 - upperY0; int len = upperY1 - upperY0;
std::copy(blockData.data() + slot, blockData.data() + slot + len, data->data() + blocksP); std::copy(blockData.data() + slot,
blockData.data() + slot + len,
data->data() + blocksP);
blocksP += len; blocksP += len;
} }
} }
std::vector<uint8_t> dataData = std::vector<uint8_t>(Level::CHUNK_TILE_COUNT); std::vector<uint8_t> dataData =
std::vector<uint8_t>(Level::CHUNK_TILE_COUNT);
chunk->getDataData(dataData); chunk->getDataData(dataData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -873,7 +879,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; 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; dataP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -882,14 +889,16 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
Level::COMPRESSED_CHUNK_SECTION_TILES) >> Level::COMPRESSED_CHUNK_SECTION_TILES) >>
1; 1;
int len = (upperY1 - upperY0) / 2; 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; dataP += len;
} }
} }
// 4J Stu - Allow ignoring light data // 4J Stu - Allow ignoring light data
if (blockLightP > -1) { if (blockLightP > -1) {
std::vector<uint8_t> blockLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> blockLightData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getBlockLightData(blockLightData); chunk->getBlockLightData(blockLightData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -898,7 +907,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; 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; blockLightP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -907,7 +918,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
1) + 1) +
(Level::COMPRESSED_CHUNK_SECTION_TILES / 2); (Level::COMPRESSED_CHUNK_SECTION_TILES / 2);
int len = (upperY1 - upperY0) / 2; int len = (upperY1 - upperY0) / 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; blockLightP += len;
} }
} }
@ -915,7 +928,8 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
// 4J Stu - Allow ignoring light data // 4J Stu - Allow ignoring light data
if (skyLightP > -1) { if (skyLightP > -1) {
std::vector<uint8_t> skyLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> skyLightData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getSkyLightData(skyLightData); chunk->getSkyLightData(skyLightData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -924,7 +938,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; 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; skyLightP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -933,7 +949,9 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
1) + 1) +
(Level::COMPRESSED_CHUNK_SECTION_TILES / 2); (Level::COMPRESSED_CHUNK_SECTION_TILES / 2);
int len = (upperY1 - upperY0) / 2; int len = (upperY1 - upperY0) / 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; skyLightP += len;
} }
} }
@ -943,9 +961,10 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk* chunk, std::vector<uint8
} }
void ConsoleSchematicFile::setBlocksAndData( void ConsoleSchematicFile::setBlocksAndData(
LevelChunk* chunk, std::vector<uint8_t>& blockData, std::vector<uint8_t>& dataData, LevelChunk* chunk, std::vector<uint8_t>& blockData,
std::vector<uint8_t> inputData, int x0, int y0, int z0, int x1, int y1, int z1, std::vector<uint8_t>& dataData, std::vector<uint8_t> inputData, int x0,
int& blocksP, int& dataP, int& blockLightP, int& skyLightP) { int y0, int z0, int x1, int y1, int z1, int& blocksP, int& dataP,
int& blockLightP, int& skyLightP) {
bool bHasLower, bHasUpper; bool bHasLower, bHasUpper;
bHasLower = bHasUpper = false; bHasLower = bHasUpper = false;
int lowerY0, lowerY1, upperY0, upperY1; int lowerY0, lowerY1, upperY0, upperY1;
@ -964,13 +983,15 @@ void ConsoleSchematicFile::setBlocksAndData(
upperY1 = y1 - Level::COMPRESSED_CHUNK_SECTION_HEIGHT; upperY1 = y1 - Level::COMPRESSED_CHUNK_SECTION_HEIGHT;
bHasUpper = true; bHasUpper = true;
} }
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
if (bHasLower) { if (bHasLower) {
int slot = x << Level::genDepthBitsPlusFour | int slot = x << Level::genDepthBitsPlusFour |
z << Level::genDepthBits | lowerY0; z << Level::genDepthBits | lowerY0;
int len = lowerY1 - 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; blocksP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -978,20 +999,23 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | upperY0) + z << Level::genDepthBits | upperY0) +
Level::COMPRESSED_CHUNK_SECTION_TILES; Level::COMPRESSED_CHUNK_SECTION_TILES;
int len = upperY1 - upperY0; 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; blocksP += len;
} }
} }
for (int x = x0; x < x1; x++)
for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
if (bHasLower) { if (bHasLower) {
int slot = (x << Level::genDepthBitsPlusFour | int slot = (x << Level::genDepthBitsPlusFour |
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; 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; dataP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -1000,14 +1024,17 @@ void ConsoleSchematicFile::setBlocksAndData(
Level::COMPRESSED_CHUNK_SECTION_TILES) >> Level::COMPRESSED_CHUNK_SECTION_TILES) >>
1; 1;
int len = (upperY1 - upperY0) / 2; 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; dataP += len;
} }
} }
// 4J Stu - Allow ignoring light data // 4J Stu - Allow ignoring light data
if (blockLightP > -1) { if (blockLightP > -1) {
std::vector<uint8_t> blockLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> blockLightData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getBlockLightData(blockLightData); chunk->getBlockLightData(blockLightData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -1016,7 +1043,9 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; 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; blockLightP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -1025,7 +1054,9 @@ void ConsoleSchematicFile::setBlocksAndData(
1) + 1) +
(Level::COMPRESSED_CHUNK_SECTION_TILES / 2); (Level::COMPRESSED_CHUNK_SECTION_TILES / 2);
int len = (upperY1 - upperY0) / 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; blockLightP += len;
} }
} }
@ -1034,7 +1065,8 @@ void ConsoleSchematicFile::setBlocksAndData(
// 4J Stu - Allow ignoring light data // 4J Stu - Allow ignoring light data
if (skyLightP > -1) { if (skyLightP > -1) {
std::vector<uint8_t> skyLightData = std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT); std::vector<uint8_t> skyLightData =
std::vector<uint8_t>(Level::HALF_CHUNK_TILE_COUNT);
chunk->getSkyLightData(skyLightData); chunk->getSkyLightData(skyLightData);
for (int x = x0; x < x1; x++) for (int x = x0; x < x1; x++)
for (int z = z0; z < z1; z++) { for (int z = z0; z < z1; z++) {
@ -1043,7 +1075,9 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | lowerY0) >> z << Level::genDepthBits | lowerY0) >>
1; 1;
int len = (lowerY1 - lowerY0) / 2; 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; skyLightP += len;
} }
if (bHasUpper) { if (bHasUpper) {
@ -1051,7 +1085,9 @@ void ConsoleSchematicFile::setBlocksAndData(
z << Level::genDepthBits | upperY0) + z << Level::genDepthBits | upperY0) +
(Level::COMPRESSED_CHUNK_SECTION_TILES / 2); (Level::COMPRESSED_CHUNK_SECTION_TILES / 2);
int len = (upperY1 - upperY0) / 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; skyLightP += len;
} }
} }

View file

@ -54,7 +54,7 @@ public:
Compression::ECompressionTypes compressionType; Compression::ECompressionTypes compressionType;
_XboxSchematicInitParam() { _XboxSchematicInitParam() {
memset(name, 0, 64 * (sizeof(wchar_t))); memset(name, 0, 64 * (sizeof(wchar_t)));
startX = startY = startZ = endX = endY = endZ = 0; startX = startY = startZ = endX = endY = endZ = 0;
bSaveMobs = false; bSaveMobs = false;
compressionType = Compression::eCompressionType_None; compressionType = Compression::eCompressionType_None;
@ -92,18 +92,19 @@ public:
int xEnd, int yEnd, int zEnd, int xEnd, int yEnd, int zEnd,
bool bSaveMobs, bool bSaveMobs,
Compression::ECompressionTypes); Compression::ECompressionTypes);
static void setBlocksAndData(LevelChunk* chunk, std::vector<uint8_t>& blockData, static void setBlocksAndData(LevelChunk* chunk,
std::vector<uint8_t>& dataData, std::vector<uint8_t> data, int x0, std::vector<uint8_t>& blockData,
int y0, int z0, int x1, int y1, int z1, std::vector<uint8_t>& dataData,
int& blocksP, int& dataP, int& blockLightP, std::vector<uint8_t> data, int x0, int y0,
int& skyLightP); int z0, int x1, int y1, int z1, int& blocksP,
int& dataP, int& blockLightP, int& skyLightP);
private: private:
void save_tags(DataOutputStream* dos); void save_tags(DataOutputStream* dos);
void load_tags(DataInputStream* dis); void load_tags(DataInputStream* dis);
static void getBlocksAndData(LevelChunk* chunk, std::vector<uint8_t>* data, int x0, static void getBlocksAndData(LevelChunk* chunk, std::vector<uint8_t>* data,
int y0, int z0, int x1, int y1, int z1, int x0, int y0, int z0, int x1, int y1, int z1,
int& blocksP, int& dataP, int& blockLightP, int& blocksP, int& dataP, int& blockLightP,
int& skyLightP); int& skyLightP);
static std::vector<std::shared_ptr<TileEntity> >* getTileEntitiesInRegion( static std::vector<std::shared_ptr<TileEntity> >* getTileEntitiesInRegion(

View file

@ -277,7 +277,6 @@ void LevelGenerationOptions::processSchematics(LevelChunk* chunk) {
delete bb; delete bb;
} }
} }
} }
void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) { void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) {
@ -288,12 +287,10 @@ void LevelGenerationOptions::processSchematicsLighting(LevelChunk* chunk) {
ApplySchematicRuleDefinition* rule = *it; ApplySchematicRuleDefinition* rule = *it;
rule->processSchematicLighting(&chunkBox, chunk); rule->processSchematicLighting(&chunkBox, chunk);
} }
} }
bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1, bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1,
int y1, int z1) { int y1, int z1) {
// As an optimisation, we can quickly discard things below a certain y which // 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 // makes most ore checks faster due to a) ores generally being below
// ground/sea level and b) tutorial world additions generally being above // ground/sea level and b) tutorial world additions generally being above
@ -513,7 +510,9 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr,
if (fileHandle) { if (fileHandle) {
uint32_t dwFileSize = grf.length(); uint32_t dwFileSize = grf.length();
uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize]; uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize];
fileHandle.read(reinterpret_cast<char*>(pbData), static_cast<std::streamsize>(dwFileSize)); fileHandle.read(
reinterpret_cast<char*>(pbData),
static_cast<std::streamsize>(dwFileSize));
if (!fileHandle) { if (!fileHandle) {
app.FatalLoadError(); app.FatalLoadError();
} }
@ -540,7 +539,8 @@ int LevelGenerationOptions::packMounted(void* pParam, int iPad, uint32_t dwErr,
if (saveHandle) { if (saveHandle) {
auto dwFileSize = std::filesystem::file_size(savePath); auto dwFileSize = std::filesystem::file_size(savePath);
uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize]; uint8_t* pbData = (uint8_t*)new uint8_t[dwFileSize];
saveHandle.read(reinterpret_cast<char*>(pbData), static_cast<std::streamsize>(dwFileSize)); saveHandle.read(reinterpret_cast<char*>(pbData),
static_cast<std::streamsize>(dwFileSize));
if (!saveHandle) { if (!saveHandle) {
app.FatalLoadError(); app.FatalLoadError();
} }

View file

@ -144,11 +144,13 @@ bool CGameNetworkManager::StartNetworkGame(Minecraft* minecraft,
std::ifstream fileHandle(grfPath, std::ios::binary); std::ifstream fileHandle(grfPath, std::ios::binary);
if (fileHandle) { if (fileHandle) {
auto dwFileSize = std::filesystem::file_size(grfPath); auto dwFileSize =
std::filesystem::file_size(grfPath);
uint8_t* pbData = uint8_t* pbData =
(uint8_t*)new uint8_t[dwFileSize]; (uint8_t*)new uint8_t[dwFileSize];
fileHandle.read(reinterpret_cast<char*>(pbData), fileHandle.read(
static_cast<std::streamsize>(dwFileSize)); reinterpret_cast<char*>(pbData),
static_cast<std::streamsize>(dwFileSize));
if (!fileHandle) { if (!fileHandle) {
app.FatalLoadError(); app.FatalLoadError();
} }

View file

@ -11,7 +11,6 @@
#include "NetworkPlayerInterface.h" #include "NetworkPlayerInterface.h"
#include "SessionInfo.h" #include "SessionInfo.h"
class ClientConnection; class ClientConnection;
class Minecraft; class Minecraft;
class CGameNetworkManager; class CGameNetworkManager;

View file

@ -451,7 +451,7 @@ std::wstring CPlatformNetworkManagerStub::GatherRTTStats() {
((NetworkPlayerQNet*)GetPlayerByIndex(i))->GetQNetPlayer(); ((NetworkPlayerQNet*)GetPlayerByIndex(i))->GetQNetPlayer();
if (!pQNetPlayer->IsLocal()) { 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()); swprintf(stat, 32, L"%d: %d/", i, pQNetPlayer->GetCurrentRtt());
stats.append(stat); stats.append(stat);
} }

View file

@ -81,7 +81,8 @@ Socket::Socket(bool response) {
if (s_serverConnection != nullptr) { if (s_serverConnection != nullptr) {
s_serverConnection->NewIncomingSocket(socket); s_serverConnection->NewIncomingSocket(socket);
} else { } else {
fprintf(stderr, fprintf(
stderr,
"SOCKET: Warning - attempted to notify server of new incoming " "SOCKET: Warning - attempted to notify server of new incoming "
"socket but s_serverConnection is nullptr\n"); "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 (!fromHost) queueIdx = SOCKET_SERVER_END;
if (queueIdx != m_end && !m_hostLocal) { if (queueIdx != m_end && !m_hostLocal) {
fprintf(stderr, fprintf(
stderr,
"SOCKET: Error pushing data to queue. End is %d but queue idx id " "SOCKET: Error pushing data to queue. End is %d but queue idx id "
"%d\n", "%d\n",
m_end, queueIdx); m_end, queueIdx);
@ -177,9 +179,9 @@ InputStream* Socket::getInputStream(bool isServerConnection) {
} else { } else {
if (s_hostInStream[m_end] == nullptr) { if (s_hostInStream[m_end] == nullptr) {
fprintf(stderr, fprintf(stderr,
"SOCKET: Warning - s_hostInStream[%d] is nullptr in " "SOCKET: Warning - s_hostInStream[%d] is nullptr in "
"getInputStream(); calling EnsureStreamsInitialised()\n", "getInputStream(); calling EnsureStreamsInitialised()\n",
m_end); m_end);
EnsureStreamsInitialised(); EnsureStreamsInitialised();
} }
return s_hostInStream[m_end]; return s_hostInStream[m_end];
@ -205,9 +207,9 @@ Socket::SocketOutputStream* Socket::getOutputStream(bool isServerConnection) {
int outIdx = 1 - m_end; int outIdx = 1 - m_end;
if (s_hostOutStream[outIdx] == nullptr) { if (s_hostOutStream[outIdx] == nullptr) {
fprintf(stderr, fprintf(stderr,
"SOCKET: Warning - s_hostOutStream[%d] is nullptr in " "SOCKET: Warning - s_hostOutStream[%d] is nullptr in "
"getOutputStream(); calling EnsureStreamsInitialised()\n", "getOutputStream(); calling EnsureStreamsInitialised()\n",
outIdx); outIdx);
EnsureStreamsInitialised(); EnsureStreamsInitialised();
} }
return s_hostOutStream[outIdx]; return s_hostOutStream[outIdx];
@ -275,7 +277,8 @@ int Socket::SocketInputStreamLocal::read(std::vector<uint8_t>& b) {
// Try and get an input range of bytes, blocking until enough bytes are // Try and get an input range of bytes, blocking until enough bytes are
// available // available
int Socket::SocketInputStreamLocal::read(std::vector<uint8_t>& b, unsigned int offset, int Socket::SocketInputStreamLocal::read(std::vector<uint8_t>& b,
unsigned int offset,
unsigned int length) { unsigned int length) {
while (m_streamOpen) { while (m_streamOpen) {
{ {
@ -326,7 +329,8 @@ void Socket::SocketOutputStreamLocal::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size()); write(b, 0, b.size());
} }
void Socket::SocketOutputStreamLocal::write(const std::vector<uint8_t>& b, unsigned int offset, void Socket::SocketOutputStreamLocal::write(const std::vector<uint8_t>& b,
unsigned int offset,
unsigned int length) { unsigned int length) {
if (m_streamOpen != true) { if (m_streamOpen != true) {
return; return;
@ -386,7 +390,8 @@ int Socket::SocketInputStreamNetwork::read(std::vector<uint8_t>& b) {
// Try and get an input range of bytes, blocking until enough bytes are // Try and get an input range of bytes, blocking until enough bytes are
// available // available
int Socket::SocketInputStreamNetwork::read(std::vector<uint8_t>& b, unsigned int offset, int Socket::SocketInputStreamNetwork::read(std::vector<uint8_t>& b,
unsigned int offset,
unsigned int length) { unsigned int length) {
while (m_streamOpen) { while (m_streamOpen) {
{ {
@ -431,15 +436,15 @@ void Socket::SocketOutputStreamNetwork::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size()); write(b, 0, b.size());
} }
void Socket::SocketOutputStreamNetwork::write(const std::vector<uint8_t>& b, unsigned int offset, void Socket::SocketOutputStreamNetwork::write(const std::vector<uint8_t>& b,
unsigned int offset,
unsigned int length) { unsigned int length) {
writeWithFlags(b, offset, length, 0); writeWithFlags(b, offset, length, 0);
} }
void Socket::SocketOutputStreamNetwork::writeWithFlags(const std::vector<uint8_t>& b, void Socket::SocketOutputStreamNetwork::writeWithFlags(
unsigned int offset, const std::vector<uint8_t>& b, unsigned int offset, unsigned int length,
unsigned int length, int flags) {
int flags) {
if (m_streamOpen != true) return; if (m_streamOpen != true) return;
if (length == 0) return; if (length == 0) return;
@ -467,15 +472,16 @@ void Socket::SocketOutputStreamNetwork::writeWithFlags(const std::vector<uint8_t
INetworkPlayer* hostPlayer = g_NetworkManager.GetHostPlayer(); INetworkPlayer* hostPlayer = g_NetworkManager.GetHostPlayer();
if (hostPlayer == nullptr) { if (hostPlayer == nullptr) {
fprintf(stderr, fprintf(
stderr,
"Trying to write to network, but the hostPlayer is nullptr\n"); "Trying to write to network, but the hostPlayer is nullptr\n");
return; return;
} }
INetworkPlayer* socketPlayer = m_socket->getPlayer(); INetworkPlayer* socketPlayer = m_socket->getPlayer();
if (socketPlayer == nullptr) { if (socketPlayer == nullptr) {
fprintf(stderr, fprintf(stderr,
"Trying to write to network, but the socketPlayer is " "Trying to write to network, but the socketPlayer is "
"nullptr\n"); "nullptr\n");
return; return;
} }

View file

@ -11,8 +11,8 @@
#include "java/InputOutputStream/InputStream.h" #include "java/InputOutputStream/InputStream.h"
#include "java/InputOutputStream/OutputStream.h" #include "java/InputOutputStream/OutputStream.h"
#include "console_helpers/C4JThread.h" // 4jcraft TODO #include "console_helpers/C4JThread.h" // 4jcraft TODO
#include "console_helpers/ThreadName.h" // 4jcraft TODO #include "console_helpers/ThreadName.h" // 4jcraft TODO
#include "Minecraft.Client/Common/src/Network/NetworkPlayerInterface.h" #include "Minecraft.Client/Common/src/Network/NetworkPlayerInterface.h"
#include "Minecraft.Client/Common/src/Network/GameNetworkManager.h" #include "Minecraft.Client/Common/src/Network/GameNetworkManager.h"
@ -30,8 +30,9 @@ public:
class SocketOutputStream : public OutputStream { class SocketOutputStream : public OutputStream {
public: public:
// The flags are those that can be used for the QNet SendData function // The flags are those that can be used for the QNet SendData function
virtual void writeWithFlags(const std::vector<uint8_t>& b, unsigned int offset, virtual void writeWithFlags(const std::vector<uint8_t>& b,
unsigned int length, int flags) { unsigned int offset, unsigned int length,
int flags) {
write(b, offset, length); write(b, offset, length);
} }
}; };
@ -49,7 +50,8 @@ private:
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual int64_t skip(int64_t n) { virtual int64_t skip(int64_t n) {
return n; return n;
@ -85,7 +87,8 @@ private:
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual int64_t skip(int64_t n) { virtual int64_t skip(int64_t n) {
return n; return n;
@ -104,8 +107,9 @@ private:
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length); unsigned int length);
virtual void writeWithFlags(const std::vector<uint8_t>& b, unsigned int offset, virtual void writeWithFlags(const std::vector<uint8_t>& b,
unsigned int length, int flags); unsigned int offset, unsigned int length,
int flags);
virtual void close(); virtual void close();
virtual void flush() {} virtual void flush() {}
}; };

View file

@ -184,11 +184,11 @@ FullTutorial::FullTutorial(int iPad, bool isTrial /*= false*/)
// END OF BASIC TUTORIAL // END OF BASIC TUTORIAL
addTask(e_Tutorial_State_Gameplay, addTask(
new ChoiceTask(this, IDS_TUTORIAL_TASK_BASIC_COMPLETE, e_Tutorial_State_Gameplay,
IDS_TUTORIAL_PROMPT_BASIC_COMPLETE, true, new ChoiceTask(this, IDS_TUTORIAL_TASK_BASIC_COMPLETE,
ACTION_MENU_A, ACTION_MENU_B, IDS_TUTORIAL_PROMPT_BASIC_COMPLETE, true, ACTION_MENU_A,
e_Tutorial_Completion_Jump_To_Last_Task)); ACTION_MENU_B, e_Tutorial_Completion_Jump_To_Last_Task));
// START OF FULL TUTORIAL // START OF FULL TUTORIAL

View file

@ -13,9 +13,8 @@
#include "Minecraft.Client/Common/src/Tutorial/Tasks/TutorialTask.h" #include "Minecraft.Client/Common/src/Tutorial/Tasks/TutorialTask.h"
#include "Minecraft.Client/Linux/Linux_UIController.h" #include "Minecraft.Client/Linux/Linux_UIController.h"
InfoTask::InfoTask( InfoTask::InfoTask(Tutorial* tutorial, int descriptionId, int promptId /*= -1*/,
Tutorial* tutorial, int descriptionId, int promptId /*= -1*/, bool requiresUserInput /*= false*/, int iMapping /*= 0*/)
bool requiresUserInput /*= false*/, int iMapping /*= 0*/)
: TutorialTask(tutorial, descriptionId, false, nullptr, true, false, : TutorialTask(tutorial, descriptionId, false, nullptr, true, false,
false) { false) {
if (requiresUserInput == true) { if (requiresUserInput == true) {

View file

@ -15,9 +15,8 @@ private:
bool CompletionMaskIsValid(); bool CompletionMaskIsValid();
public: public:
InfoTask( InfoTask(Tutorial* tutorial, int descriptionId, int promptId = -1,
Tutorial* tutorial, int descriptionId, int promptId = -1, bool requiresUserInput = false, int iMapping = 0);
bool requiresUserInput = false, int iMapping = 0);
virtual bool isCompleted(); virtual bool isCompleted();
virtual int getPromptId(); virtual int getPromptId();
virtual void setAsCurrentTask(bool active = true); virtual void setAsCurrentTask(bool active = true);

View file

@ -1944,7 +1944,7 @@ void Tutorial::debugResetPlayerSavedProgress(int iPad) {
GAME_SETTINGS* pGameSettings = GAME_SETTINGS* pGameSettings =
(GAME_SETTINGS*)ProfileManager.GetGameDefinedProfileData(iPad); (GAME_SETTINGS*)ProfileManager.GetGameDefinedProfileData(iPad);
memset(pGameSettings->ucTutorialCompletion, 0, memset(pGameSettings->ucTutorialCompletion, 0,
TUTORIAL_PROFILE_STORAGE_BYTES); TUTORIAL_PROFILE_STORAGE_BYTES);
pGameSettings->uiSpecialTutorialBitmask = 0; pGameSettings->uiSpecialTutorialBitmask = 0;
} }
@ -2366,8 +2366,8 @@ void Tutorial::tick() {
} }
} }
if (m_hintDisplayed && if (m_hintDisplayed && (lastMessageTime + m_iTutorialDisplayMessageTime) <
(lastMessageTime + m_iTutorialDisplayMessageTime) < PlatformTime::GetTickCount()) { PlatformTime::GetTickCount()) {
m_hintDisplayed = false; m_hintDisplayed = false;
} }
@ -2402,7 +2402,8 @@ bool Tutorial::setMessage(PopupMessageDetails* message) {
m_lastMessageState == m_CurrentState && m_lastMessageState == m_CurrentState &&
message->isSameContent(m_lastMessage) && message->isSameContent(m_lastMessage) &&
(!message->m_isReminder || (!message->m_isReminder ||
((lastMessageTime + m_iTutorialReminderTime) > PlatformTime::GetTickCount() && ((lastMessageTime + m_iTutorialReminderTime) >
PlatformTime::GetTickCount() &&
message->m_isReminder))) { message->m_isReminder))) {
delete message; delete message;
return false; return false;
@ -2412,7 +2413,8 @@ bool Tutorial::setMessage(PopupMessageDetails* message) {
(message->m_messageId > 0 || !message->m_messageString.empty())) { (message->m_messageId > 0 || !message->m_messageString.empty())) {
m_lastMessageState = m_CurrentState; m_lastMessageState = m_CurrentState;
if (!message->m_replaceCurrent) lastMessageTime = PlatformTime::GetTickCount(); if (!message->m_replaceCurrent)
lastMessageTime = PlatformTime::GetTickCount();
std::wstring text; std::wstring text;
if (!message->m_messageString.empty()) { if (!message->m_messageString.empty()) {

View file

@ -145,8 +145,8 @@ std::vector<uint8_t> ArchiveFile::getFile(const std::wstring& filename) {
uncompressedBuffer, &decompressedSize, out.data() + 4, uncompressedBuffer, &decompressedSize, out.data() + 4,
out.size() - 4); out.size() - 4);
out = std::vector<uint8_t>(uncompressedBuffer,
out = std::vector<uint8_t>(uncompressedBuffer, uncompressedBuffer + decompressedSize); uncompressedBuffer + decompressedSize);
delete[] uncompressedBuffer; delete[] uncompressedBuffer;
} }

View file

@ -630,7 +630,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() {
} }
} }
*/ */
std::vector<Recipy*>* recipes = ((Recipes*)Recipes::getInstance())->getRecipies(); std::vector<Recipy*>* recipes =
((Recipes*)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
int iRecipeC = (int)recipes->size(); int iRecipeC = (int)recipes->size();
@ -871,7 +872,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() {
// run through the canbemade list and update the icons displayed // run through the canbemade list and update the icons displayed
int iIndex = 0; int iIndex = 0;
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
@ -993,7 +995,8 @@ void IUIScene_CraftingMenu::UpdateHighlight() {
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateVerticalSlots() { void IUIScene_CraftingMenu::UpdateVerticalSlots() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
@ -1064,7 +1067,8 @@ void IUIScene_CraftingMenu::UpdateVerticalSlots() {
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::DisplayIngredients() { void IUIScene_CraftingMenu::DisplayIngredients() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
@ -1231,7 +1235,8 @@ void IUIScene_CraftingMenu::DisplayIngredients() {
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) { void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) {
int iIDSString = 0; int iIDSString = 0;
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
@ -1319,7 +1324,8 @@ void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) {
// //
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateTooltips() { void IUIScene_CraftingMenu::UpdateTooltips() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies(); // std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired = Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray(); Recipes::getInstance()->getRecipeIngredientsArray();
// Update tooltips // Update tooltips

View file

@ -1,7 +1,6 @@
#include <thread> #include <thread>
#include <chrono> #include <chrono>
#include "IUIScene_PauseMenu.h" #include "IUIScene_PauseMenu.h"
#include "Minecraft.Client/Common/src/UI/UIScene.h" #include "Minecraft.Client/Common/src/UI/UIScene.h"
#include "minecraft/client/Minecraft.h" #include "minecraft/client/Minecraft.h"

View file

@ -599,7 +599,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(
LeaderboardEntry* leaderboardEntry = LeaderboardEntry* leaderboardEntry =
&(m_leaderboard.m_entries[leaderboardEntryIndex]); &(m_leaderboard.m_entries[leaderboardEntryIndex]);
memset(leaderboardEntry, 0, sizeof(LeaderboardEntry)); memset(leaderboardEntry, 0, sizeof(LeaderboardEntry));
leaderboardEntry->m_xuid = statsRow->m_uid; leaderboardEntry->m_xuid = statsRow->m_uid;
// Copy the rank // Copy the rank
@ -635,7 +635,7 @@ void UIScene_LeaderboardsMenu::CopyLeaderboardEntry(
// Copy the other columns // Copy the other columns
for (unsigned int i = 0; i < statsRow->m_statsSize; i++) { for (unsigned int i = 0; i < statsRow->m_statsSize; i++) {
leaderboardEntry->m_columns[i] = statsRow->m_statsData[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) { if (!isDistanceLeaderboard) {
unsigned int displayValue = leaderboardEntry->m_columns[i]; unsigned int displayValue = leaderboardEntry->m_columns[i];
if (displayValue > 99999) displayValue = 99999; if (displayValue > 99999) displayValue = 99999;

View file

@ -270,7 +270,7 @@ void UIScene_LoadMenu::tick() {
unsigned int uiHostOptions = 0; unsigned int uiHostOptions = 0;
char szSeed[50]; char szSeed[50];
memset(szSeed, 0, 50); memset(szSeed, 0, 50);
app.GetImageTextData( app.GetImageTextData(
m_pbThumbnailData, m_uiThumbnailSize, (unsigned char*)&szSeed, m_pbThumbnailData, m_uiThumbnailSize, (unsigned char*)&szSeed,
uiHostOptions, bHostOptionsRead, m_MoreOptionsParams.dwTexturePack); uiHostOptions, bHostOptionsRead, m_MoreOptionsParams.dwTexturePack);

View file

@ -1,7 +1,6 @@
#include <thread> #include <thread>
#include <chrono> #include <chrono>
#include "Minecraft.Client/Common/src/UI/UI.h" #include "Minecraft.Client/Common/src/UI/UI.h"
#include "UIScene_LoadOrJoinMenu.h" #include "UIScene_LoadOrJoinMenu.h"
@ -1099,7 +1098,7 @@ void UIScene_LoadOrJoinMenu::UpdateGamesList() {
} }
SessionID selectedSessionId; SessionID selectedSessionId;
memset(&selectedSessionId, 0, sizeof(SessionID)); memset(&selectedSessionId, 0, sizeof(SessionID));
if (pSelectedSession != nullptr) if (pSelectedSession != nullptr)
selectedSessionId = pSelectedSession->sessionId; selectedSessionId = pSelectedSession->sessionId;
pSelectedSession = nullptr; pSelectedSession = nullptr;
@ -1476,7 +1475,7 @@ int UIScene_LoadOrJoinMenu::SaveOptionsDialogReturned(
// bring up a keyboard // bring up a keyboard
wchar_t wSaveName[128]; wchar_t wSaveName[128];
// CD - Fix - We must memset the SaveName // CD - Fix - We must memset the SaveName
memset(wSaveName, 0, 128 * sizeof(wchar_t)); memset(wSaveName, 0, 128 * sizeof(wchar_t));
mbstowcs( mbstowcs(
wSaveName, wSaveName,
pClass pClass
@ -1722,7 +1721,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) {
// on saving games that // on saving games that
std::uint8_t bTextMetadata[88]; std::uint8_t bTextMetadata[88];
memset(bTextMetadata, 0, 88); memset(bTextMetadata, 0, 88);
unsigned int hostOptions = unsigned int hostOptions =
app.getRemoteStorage()->getSaveHostOptions(); app.getRemoteStorage()->getSaveHostOptions();
int iTextMetadataBytes = app.CreateImageTextData( int iTextMetadataBytes = app.CreateImageTextData(
@ -1898,7 +1897,7 @@ int UIScene_LoadOrJoinMenu::DownloadSonyCrossSaveThreadProc(void* lpParameter) {
// for use on saving games that // for use on saving games that
std::uint8_t bTextMetadata[88]; std::uint8_t bTextMetadata[88];
memset(bTextMetadata, 0, 88); memset(bTextMetadata, 0, 88);
unsigned int remoteHostOptions = unsigned int remoteHostOptions =
app.getRemoteStorage()->getSaveHostOptions(); app.getRemoteStorage()->getSaveHostOptions();
app.SetGameHostOption(eGameHostOption_All, app.SetGameHostOption(eGameHostOption_All,

View file

@ -10,7 +10,6 @@
#include "minecraft/client/Minecraft.h" #include "minecraft/client/Minecraft.h"
#include "UIScene_MainMenu.h" #include "UIScene_MainMenu.h"
Random* UIScene_MainMenu::random = new Random(); Random* UIScene_MainMenu::random = new Random();
int UIScene_MainMenu::eNavigateWhenReady = -1; int UIScene_MainMenu::eNavigateWhenReady = -1;
@ -242,13 +241,13 @@ void UIScene_MainMenu::handlePress(F64 controlId, F64 childId) {
&UIScene_MainMenu::UnlockFullGame_SignInReturned; &UIScene_MainMenu::UnlockFullGame_SignInReturned;
break; break;
case eControl_Exit: { case eControl_Exit: {
unsigned int uiIDA[2]; unsigned int uiIDA[2];
uiIDA[0] = IDS_CONFIRM_CANCEL; uiIDA[0] = IDS_CONFIRM_CANCEL;
uiIDA[1] = IDS_CONFIRM_OK; uiIDA[1] = IDS_CONFIRM_OK;
ui.RequestErrorMessage( ui.RequestErrorMessage(IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA,
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, 2, XUSER_INDEX_ANY,
XUSER_INDEX_ANY, &UIScene_MainMenu::ExitGameReturned, this); &UIScene_MainMenu::ExitGameReturned, this);
} break; } break;
default: default:
__debugbreak(); __debugbreak();
@ -303,8 +302,7 @@ void UIScene_MainMenu::RunAction(int iPad) {
void UIScene_MainMenu::customDraw(IggyCustomDrawCallbackRegion* region) { void UIScene_MainMenu::customDraw(IggyCustomDrawCallbackRegion* region) {
if (std::char_traits<char16_t>::compare(region->name, u"Splash", 6) == 0) { if (std::char_traits<char16_t>::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); glRotatef(-17, 0, 0, 1);
float sss = 1.8f - std::abs(sinf(System::currentTimeMillis() % 1000 / float sss = 1.8f - std::abs(sinf(System::currentTimeMillis() % 1000 /
1000.0f * std::numbers::pi * 2) * 1000.0f * std::numbers::pi * 2) *
0.1f); 0.1f);
sss *= (m_fScreenWidth / m_fRawWidth); sss *= (m_fScreenWidth / m_fRawWidth);
@ -874,10 +872,10 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) {
// you can't see the store // you can't see the store
unsigned int uiIDA[1]; unsigned int uiIDA[1];
uiIDA[0] = IDS_CONFIRM_OK; uiIDA[0] = IDS_CONFIRM_OK;
ui.RequestErrorMessage( ui.RequestErrorMessage(IDS_ONLINE_SERVICE_TITLE,
IDS_ONLINE_SERVICE_TITLE, IDS_CONTENT_RESTRICTION, IDS_CONTENT_RESTRICTION, uiIDA, 1,
uiIDA, 1, ProfileManager.GetPrimaryPad(), nullptr, ProfileManager.GetPrimaryPad(),
this); nullptr, this);
#endif #endif
} else { } else {
ProfileManager.SetLockedProfile(iPad); ProfileManager.SetLockedProfile(iPad);
@ -897,8 +895,8 @@ void UIScene_MainMenu::RunUnlockOrDLC(int iPad) {
} else { } else {
unsigned int uiIDA[1]; unsigned int uiIDA[1];
uiIDA[0] = IDS_OK; uiIDA[0] = IDS_OK;
ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, ui.RequestErrorMessage(IDS_PRO_NOTONLINE_TITLE, IDS_PRO_NOTONLINE_TEXT,
IDS_PRO_NOTONLINE_TEXT, uiIDA, 1); uiIDA, 1);
} }
} }

View file

@ -42,7 +42,6 @@ void UIScene_TrialExitUpsell::handleInput(int iPad, int key, bool repeat,
if (ProfileManager.IsSignedIn(iPad)) { if (ProfileManager.IsSignedIn(iPad)) {
// CD - Added for audio // CD - Added for audio
ui.PlayUISFX(eSFX_Press); ui.PlayUISFX(eSFX_Press);
} }
break; break;
} }

View file

@ -237,7 +237,7 @@ void UIScene_Credits::tick() {
wchar_t* creditsString = new wchar_t[128]; wchar_t* creditsString = new wchar_t[128];
if (pDef->m_iStringID[0] == NO_TRANSLATED_STRING) { if (pDef->m_iStringID[0] == NO_TRANSLATED_STRING) {
memset(creditsString, 0, 128); memset(creditsString, 0, 128);
memcpy(creditsString, sanitisedString.c_str(), memcpy(creditsString, sanitisedString.c_str(),
sizeof(wchar_t) * sanitisedString.length()); sizeof(wchar_t) * sanitisedString.length());
} else if (pDef->m_iStringID[1] != NO_TRANSLATED_STRING) { } else if (pDef->m_iStringID[1] != NO_TRANSLATED_STRING) {

View file

@ -5,32 +5,31 @@
#include "UIScene_LanguageSelector.h" #include "UIScene_LanguageSelector.h"
// strings for buttons in the list // strings for buttons in the list
const unsigned int UIScene_LanguageSelector::m_uiHTPButtonNameA[]= const unsigned int UIScene_LanguageSelector::m_uiHTPButtonNameA[] = {
{ IDS_LANG_SYSTEM,
IDS_LANG_SYSTEM, IDS_LANG_ENGLISH,
IDS_LANG_ENGLISH, IDS_LANG_GERMAN,
IDS_LANG_GERMAN, IDS_LANG_SPANISH_SPAIN,
IDS_LANG_SPANISH_SPAIN, IDS_LANG_SPANISH_LATIN_AMERICA,
IDS_LANG_SPANISH_LATIN_AMERICA, IDS_LANG_FRENCH,
IDS_LANG_FRENCH, IDS_LANG_ITALIAN,
IDS_LANG_ITALIAN, IDS_LANG_PORTUGUESE_PORTUGAL,
IDS_LANG_PORTUGUESE_PORTUGAL, IDS_LANG_PORTUGUESE_BRAZIL,
IDS_LANG_PORTUGUESE_BRAZIL, IDS_LANG_JAPANESE,
IDS_LANG_JAPANESE, IDS_LANG_KOREAN,
IDS_LANG_KOREAN, IDS_LANG_CHINESE_TRADITIONAL,
IDS_LANG_CHINESE_TRADITIONAL, IDS_LANG_CHINESE_SIMPLIFIED,
IDS_LANG_CHINESE_SIMPLIFIED, IDS_LANG_DANISH,
IDS_LANG_DANISH, IDS_LANG_FINISH,
IDS_LANG_FINISH, IDS_LANG_DUTCH,
IDS_LANG_DUTCH, IDS_LANG_POLISH,
IDS_LANG_POLISH, IDS_LANG_RUSSIAN,
IDS_LANG_RUSSIAN, IDS_LANG_SWEDISH,
IDS_LANG_SWEDISH, IDS_LANG_NORWEGIAN,
IDS_LANG_NORWEGIAN, // IDS_LANG_SLOVAK,
// IDS_LANG_SLOVAK, // IDS_LANG_CZECH,
// IDS_LANG_CZECH, IDS_LANG_GREEK,
IDS_LANG_GREEK, IDS_LANG_TURKISH,
IDS_LANG_TURKISH,
}; };
UIScene_LanguageSelector::UIScene_LanguageSelector(int iPad, void* initData, UIScene_LanguageSelector::UIScene_LanguageSelector(int iPad, void* initData,

View file

@ -8,35 +8,34 @@
class UIScene_LanguageSelector : public UIScene { class UIScene_LanguageSelector : public UIScene {
public: public:
enum ELangButtons enum ELangButtons {
{ eLanguageSelector_LabelNone = -1,
eLanguageSelector_LabelNone = -1, eLanguageSelector_system,
eLanguageSelector_system, eLanguageSelector_EN_US,
eLanguageSelector_EN_US, eLanguageSelector_DE_DE,
eLanguageSelector_DE_DE, eLanguageSelector_ES_ES,
eLanguageSelector_ES_ES, eLanguageSelector_ES_MX,
eLanguageSelector_ES_MX, eLanguageSelector_FR_FR,
eLanguageSelector_FR_FR, eLanguageSelector_IT_IT,
eLanguageSelector_IT_IT, eLanguageSelector_PT_PT,
eLanguageSelector_PT_PT, eLanguageSelector_PT_BR,
eLanguageSelector_PT_BR, eLanguageSelector_JA_JP,
eLanguageSelector_JA_JP, eLanguageSelector_KO_KR,
eLanguageSelector_KO_KR, eLanguageSelector_CN_TW,
eLanguageSelector_CN_TW, eLanguageSelector_CN_CN,
eLanguageSelector_CN_CN, eLanguageSelector_DA_DK,
eLanguageSelector_DA_DK, eLanguageSelector_FI_FI,
eLanguageSelector_FI_FI, eLanguageSelector_NL_NL,
eLanguageSelector_NL_NL, eLanguageSelector_PL_PL,
eLanguageSelector_PL_PL, eLanguageSelector_RU_RU,
eLanguageSelector_RU_RU, eLanguageSelector_SV_SE,
eLanguageSelector_SV_SE, eLanguageSelector_NB_NO,
eLanguageSelector_NB_NO, eLanguageSelector_SK_SK,
eLanguageSelector_SK_SK, eLanguageSelector_CZ_CZ,
eLanguageSelector_CZ_CZ, eLanguageSelector_EL_GR,
eLanguageSelector_EL_GR, eLanguageSelector_TR_TR,
eLanguageSelector_TR_TR, eLanguageSelector_MAX
eLanguageSelector_MAX };
};
private: private:
enum EControls { enum EControls {
@ -73,58 +72,28 @@ protected:
void handlePress(F64 controlId, F64 childId); void handlePress(F64 controlId, F64 childId);
}; };
const int uiLangMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = const int uiLangMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = {
{ MINECRAFT_LANGUAGE_DEFAULT, XC_LANGUAGE_ENGLISH, XC_LANGUAGE_GERMAN,
MINECRAFT_LANGUAGE_DEFAULT, XC_LANGUAGE_SPANISH, XC_LANGUAGE_SPANISH, XC_LANGUAGE_FRENCH,
XC_LANGUAGE_ENGLISH, XC_LANGUAGE_ITALIAN, XC_LANGUAGE_PORTUGUESE, XC_LANGUAGE_PORTUGUESE,
XC_LANGUAGE_GERMAN, XC_LANGUAGE_JAPANESE, XC_LANGUAGE_KOREAN, XC_LANGUAGE_TCHINESE,
XC_LANGUAGE_SPANISH, XC_LANGUAGE_SCHINESE, XC_LANGUAGE_DANISH, XC_LANGUAGE_FINISH,
XC_LANGUAGE_SPANISH, XC_LANGUAGE_DUTCH, XC_LANGUAGE_POLISH, XC_LANGUAGE_RUSSIAN,
XC_LANGUAGE_FRENCH, XC_LANGUAGE_SWEDISH, XC_LANGUAGE_BNORWEGIAN, XC_LANGUAGE_SLOVAK,
XC_LANGUAGE_ITALIAN, XC_LANGUAGE_CZECH, XC_LANGUAGE_GREEK, XC_LANGUAGE_TURKISH,
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] = const int uiLocaleMap[UIScene_LanguageSelector::eLanguageSelector_MAX] = {
{ MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, XC_LOCALE_SPAIN,
MINECRAFT_LANGUAGE_DEFAULT, XC_LOCALE_LATIN_AMERICA, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, XC_LOCALE_PORTUGAL,
XC_LOCALE_SPAIN, XC_LOCALE_BRAZIL, MINECRAFT_LANGUAGE_DEFAULT,
XC_LOCALE_LATIN_AMERICA, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
XC_LOCALE_PORTUGAL, MINECRAFT_LANGUAGE_DEFAULT, MINECRAFT_LANGUAGE_DEFAULT,
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,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
MINECRAFT_LANGUAGE_DEFAULT,
}; };

View file

@ -117,8 +117,7 @@ void UIScene_DeathMenu::handlePress(F64 controlId, F64 childId) {
ui.RequestAlertMessage( ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2,
m_iPad, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned,
&IUIScene_PauseMenu::ExitGameDialogReturned,
(void*)GetCallbackUniqueId()); (void*)GetCallbackUniqueId());
} }
} }

View file

@ -235,7 +235,7 @@ void UIScene_EndPoem::updateNoise() {
colour = eHTMLColor_9; colour = eHTMLColor_9;
else if (randomVal == 2) else if (randomVal == 2)
colour = eHTMLColor_a; colour = eHTMLColor_a;
memset(replacements, 0, 64 * sizeof(wchar_t)); memset(replacements, 0, 64 * sizeof(wchar_t));
swprintf( swprintf(
replacements, 64, replacements, 64,
L"<font color=\"#%08x\" shadowcolor=\"#80000000\">%ls</font>", L"<font color=\"#%08x\" shadowcolor=\"#80000000\">%ls</font>",

View file

@ -91,7 +91,8 @@ void UIScene_PauseMenu::tick() { UIScene::tick(); }
void UIScene_PauseMenu::updateTooltips() { void UIScene_PauseMenu::updateTooltips() {
// bool bUserisClientSide = ProfileManager.IsSignedInLive(m_iPad); // bool bUserisClientSide = ProfileManager.IsSignedInLive(m_iPad);
// bool bIsisPrimaryHost = // bool bIsisPrimaryHost =
// g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad() == m_iPad); // g_NetworkManager.IsHost() && (ProfileManager.GetPrimaryPad() ==
// m_iPad);
int iY = -1; int iY = -1;
int iRB = -1; int iRB = -1;
@ -333,15 +334,13 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) {
IDS_EXIT_GAME, IDS_EXIT_GAME,
IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE, IDS_CONFIRM_EXIT_GAME_CONFIRM_DISCONNECT_SAVE,
uiIDA, 3, m_iPad, uiIDA, 3, m_iPad,
&UIScene_PauseMenu:: &UIScene_PauseMenu::ExitGameSaveDialogReturned,
ExitGameSaveDialogReturned,
(void*)GetCallbackUniqueId()); (void*)GetCallbackUniqueId());
} else { } else {
ui.RequestAlertMessage( ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 3,
3, m_iPad, m_iPad,
&UIScene_PauseMenu:: &UIScene_PauseMenu::ExitGameSaveDialogReturned,
ExitGameSaveDialogReturned,
(void*)GetCallbackUniqueId()); (void*)GetCallbackUniqueId());
} }
} else { } else {
@ -350,8 +349,7 @@ void UIScene_PauseMenu::handlePress(F64 controlId, F64 childId) {
ui.RequestAlertMessage( ui.RequestAlertMessage(
IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2, IDS_EXIT_GAME, IDS_CONFIRM_EXIT_GAME, uiIDA, 2,
m_iPad, m_iPad, &IUIScene_PauseMenu::ExitGameDialogReturned,
&IUIScene_PauseMenu::ExitGameDialogReturned,
(void*)GetCallbackUniqueId()); (void*)GetCallbackUniqueId());
} }
} }

View file

@ -5,7 +5,6 @@
#include "console_helpers/StringHelpers.h" #include "console_helpers/StringHelpers.h"
#define KEYBOARD_DONE_TIMER_ID 0 #define KEYBOARD_DONE_TIMER_ID 0
#define KEYBOARD_DONE_TIMER_TIME 100 #define KEYBOARD_DONE_TIMER_TIME 100

View file

@ -316,17 +316,20 @@ UIController::EFont UIController::getFontForLanguage(int language) {
UITTFFont* UIController::createFont(EFont fontLanguage) { UITTFFont* UIController::createFont(EFont fontLanguage) {
switch (fontLanguage) { switch (fontLanguage) {
case eFont_Japanese: case eFont_Japanese:
return new UITTFFont("Mojangles_TTF_jaJP", return new UITTFFont(
"Minecraft.Client/Common/Media/font/JPN/DFGMaruGothic-Md.ttf", "Mojangles_TTF_jaJP",
0x2022); // JPN "Minecraft.Client/Common/Media/font/JPN/DFGMaruGothic-Md.ttf",
0x2022); // JPN
case eFont_TradChinese: case eFont_TradChinese:
return new UITTFFont("Mojangles_TTF_cnTD", return new UITTFFont(
"Minecraft.Client/Common/Media/font/CHT/DFHeiMedium-B5.ttf", "Mojangles_TTF_cnTD",
0x2022); // CHT "Minecraft.Client/Common/Media/font/CHT/DFHeiMedium-B5.ttf",
0x2022); // CHT
case eFont_Korean: case eFont_Korean:
return new UITTFFont("Mojangles_TTF_koKR", return new UITTFFont(
"Minecraft.Client/Common/Media/font/KOR/BOKMSD.ttf", "Mojangles_TTF_koKR",
0x2022); // KOR "Minecraft.Client/Common/Media/font/KOR/BOKMSD.ttf",
0x2022); // KOR
// 4J-JEV, Cyrillic characters have been added to this font now, // 4J-JEV, Cyrillic characters have been added to this font now,
// (4/July/14) XC_LANGUAGE_RUSSIAN and XC_LANGUAGE_GREEK: // (4/July/14) XC_LANGUAGE_RUSSIAN and XC_LANGUAGE_GREEK:
default: default:
@ -795,20 +798,16 @@ UIController::ExternalFunctionCallback(void* user_callback_data, Iggy* player,
// RENDERING // RENDERING
void UIController::renderScenes() { void UIController::renderScenes() {
// Only render player scenes if the game is started // Only render player scenes if the game is started
if (app.GetGameStarted() && if (app.GetGameStarted() &&
!m_groups[eUIGroup_Fullscreen]->hidesLowerScenes()) { !m_groups[eUIGroup_Fullscreen]->hidesLowerScenes()) {
for (int i = eUIGroup_Player1; i < eUIGroup_COUNT; ++i) { for (int i = eUIGroup_Player1; i < eUIGroup_COUNT; ++i) {
m_groups[i]->render(); m_groups[i]->render();
} }
} }
// Always render the fullscreen group // Always render the fullscreen group
m_groups[eUIGroup_Fullscreen]->render(); m_groups[eUIGroup_Fullscreen]->render();
#if defined(ENABLE_IGGY_PERFMON) #if defined(ENABLE_IGGY_PERFMON)
if (m_iggyPerfmonEnabled) { if (m_iggyPerfmonEnabled) {
@ -939,7 +938,7 @@ void UIController::setupCustomDrawGameState() {
m_customRenderingClearRect.bottom = LONG_MIN; m_customRenderingClearRect.bottom = LONG_MIN;
#if defined(_WINDOWS64) #if defined(_WINDOWS64)
RenderManager.StartFrame(); RenderManager.StartFrame();
gdraw_D3D11_setViewport_4J(); gdraw_D3D11_setViewport_4J();
#elif defined(__linux__) #elif defined(__linux__)
@ -953,7 +952,7 @@ void UIController::setupCustomDrawGameState() {
// RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &m_customRenderingClearRect); // RenderManager.Clear(GL_DEPTH_BUFFER_BIT, &m_customRenderingClearRect);
// glClear(GL_DEPTH_BUFFER_BIT); // glClear(GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION); glMatrixMode(GL_PROJECTION);
glLoadIdentity(); glLoadIdentity();
glOrtho(0, m_fScreenWidth, m_fScreenHeight, 0, 1000, 3000); glOrtho(0, m_fScreenWidth, m_fScreenHeight, 0, 1000, 3000);
glMatrixMode(GL_MODELVIEW); glMatrixMode(GL_MODELVIEW);
@ -962,7 +961,6 @@ void UIController::setupCustomDrawGameState() {
glEnable(GL_DEPTH_TEST); glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL); glDepthFunc(GL_LEQUAL);
glDepthMask(true); glDepthMask(true);
} }
void UIController::setupCustomDrawMatrices(UIScene* scene, void UIController::setupCustomDrawMatrices(UIScene* scene,
@ -1142,7 +1140,8 @@ void UIController::registerSubstitutionTexture(const std::wstring& textureName,
// Remove it if it already exists // Remove it if it already exists
unregisterSubstitutionTexture(textureName, false); unregisterSubstitutionTexture(textureName, false);
m_substitutionTextures[textureName] = std::vector<uint8_t>(pbData, pbData + dwLength); m_substitutionTextures[textureName] =
std::vector<uint8_t>(pbData, pbData + dwLength);
} }
void UIController::unregisterSubstitutionTexture( void UIController::unregisterSubstitutionTexture(

View file

@ -147,7 +147,8 @@ private:
static std::uint32_t m_dwTrialTimerLimitSecs; static std::uint32_t m_dwTrialTimerLimitSecs;
std::unordered_map<std::wstring, std::vector<uint8_t>> m_substitutionTextures; std::unordered_map<std::wstring, std::vector<uint8_t>>
m_substitutionTextures;
typedef struct _CachedMovieData { typedef struct _CachedMovieData {
std::vector<uint8_t> m_ba; std::vector<uint8_t> m_ba;

View file

@ -145,7 +145,6 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) {
if (itRef != m_componentRefCount.end() && itRef->second.second) { if (itRef != m_componentRefCount.end() && itRef->second.second) {
if ((*it)->isVisible()) { if ((*it)->isVisible()) {
(*it)->render(width, height, viewport); (*it)->render(width, height, viewport);
} }
} }
} }
@ -162,7 +161,6 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) {
m_sceneStack[lowestRenderable]->getSceneType() == m_sceneStack[lowestRenderable]->getSceneType() ==
eUIScene_Timer)) { eUIScene_Timer)) {
m_sceneStack[lowestRenderable]->render(width, height, viewport); m_sceneStack[lowestRenderable]->render(width, height, viewport);
} }
} }
} }

View file

@ -547,7 +547,7 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region,
// Setup GDraw, normal game render states and matrices // Setup GDraw, normal game render states and matrices
// CustomDrawData *customDrawRegion = // CustomDrawData *customDrawRegion =
// ui.setupCustomDraw(this,region); // ui.setupCustomDraw(this,region);
CustomDrawData* customDrawRegion = CustomDrawData* customDrawRegion =
ui.calculateCustomDraw(region); ui.calculateCustomDraw(region);
ui.beginIggyCustomDraw4J(region, customDrawRegion); ui.beginIggyCustomDraw4J(region, customDrawRegion);
ui.setupCustomDrawGameState(); ui.setupCustomDrawGameState();
@ -558,14 +558,13 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region,
if (!useCommandBuffers || m_needsCacheRendered) { if (!useCommandBuffers || m_needsCacheRendered) {
if (useCommandBuffers) RenderManager.CBuffStart(list, true); if (useCommandBuffers) RenderManager.CBuffStart(list, true);
ui.setupCustomDrawMatrices(this, customDrawRegion); ui.setupCustomDrawMatrices(this, customDrawRegion);
_customDrawSlotControl(customDrawRegion, iPad, item, fAlpha, _customDrawSlotControl(customDrawRegion, iPad, item, fAlpha,
isFoil, bDecorations, isFoil, bDecorations,
useCommandBuffers); useCommandBuffers);
delete customDrawRegion; delete customDrawRegion;
// Draw all the cached slots
// Draw all the cached slots
for (auto it = m_cachedSlotDraw.begin(); for (auto it = m_cachedSlotDraw.begin();
it != m_cachedSlotDraw.end(); ++it) { it != m_cachedSlotDraw.end(); ++it) {
CachedSlotDrawData* drawData = *it; CachedSlotDrawData* drawData = *it;
@ -590,7 +589,7 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region,
pMinecraft->player = oldPlayer; pMinecraft->player = oldPlayer;
} else { } else {
CachedSlotDrawData* drawData = new CachedSlotDrawData(); CachedSlotDrawData* drawData = new CachedSlotDrawData();
drawData->item = item; drawData->item = item;
drawData->fAlpha = fAlpha; drawData->fAlpha = fAlpha;
drawData->isFoil = isFoil; drawData->isFoil = isFoil;
@ -598,7 +597,6 @@ void UIScene::customDrawSlotControl(IggyCustomDrawCallbackRegion* region,
drawData->customDrawRegion = ui.calculateCustomDraw(region); drawData->customDrawRegion = ui.calculateCustomDraw(region);
m_cachedSlotDraw.push_back(drawData); m_cachedSlotDraw.push_back(drawData);
} }
} else { } else {
// Setup GDraw, normal game render states and matrices // Setup GDraw, normal game render states and matrices
@ -676,12 +674,11 @@ void UIScene::_customDrawSlotControl(CustomDrawData* region, int iPad,
glTranslatef((float)-(sx + sxoffs), (float)-(sy + syoffs), 0); 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( m_pItemRenderer->renderAndDecorateItem(
pMinecraft->font, pMinecraft->textures, item, x, y, scaleX, scaleY, pMinecraft->font, pMinecraft->textures, item, x, y, scaleX, scaleY,
fAlpha, isFoil, false, !usingCommandBuffer); fAlpha, isFoil, false, !usingCommandBuffer);
if (pop > 0) { if (pop > 0) {
glPopMatrix(); glPopMatrix();
} }

View file

@ -21,8 +21,7 @@ CConsoleMinecraftApp app;
CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() {} CConsoleMinecraftApp::CConsoleMinecraftApp() : CMinecraftApp() {}
void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) { void CConsoleMinecraftApp::SetRichPresenceContext(int iPad, int contextId) {}
}
void CConsoleMinecraftApp::StoreLaunchData() {} void CConsoleMinecraftApp::StoreLaunchData() {}
void CConsoleMinecraftApp::ExitGame() { void CConsoleMinecraftApp::ExitGame() {

View file

@ -547,7 +547,7 @@ int32_t InitDevice() {
uint32_t numFeatureLevels = ARRAYSIZE(featureLevels); uint32_t numFeatureLevels = ARRAYSIZE(featureLevels);
DXGI_SWAP_CHAIN_DESC sd; DXGI_SWAP_CHAIN_DESC sd;
memset(&sd, 0, sizeof(sd)); memset(&sd, 0, sizeof(sd));
sd.BufferCount = 1; sd.BufferCount = 1;
sd.BufferDesc.Width = width; sd.BufferDesc.Width = width;
sd.BufferDesc.Height = height; sd.BufferDesc.Height = height;
@ -763,24 +763,21 @@ int main(int argc, const char* argv[]) {
ui.setScreenSize(fbw, fbh); ui.setScreenSize(fbw, fbh);
} }
app.UpdateTime(); app.UpdateTime();
InputManager.Tick(); InputManager.Tick();
ProfileManager.Tick(); ProfileManager.Tick();
StorageManager.Tick(); StorageManager.Tick();
RenderManager.Tick();
RenderManager.Tick();
// Tick the social networking manager. // Tick the social networking manager.
// CSocialManager::Instance()->Tick(); // CSocialManager::Instance()->Tick();
// Tick sentient. // Tick sentient.
// SentientManager.Tick(); // SentientManager.Tick();
g_NetworkManager.DoWork();
g_NetworkManager.DoWork();
// Render game graphics. // Render game graphics.
#if defined(ENABLE_JAVA_GUIS) #if defined(ENABLE_JAVA_GUIS)
@ -824,7 +821,7 @@ int main(int argc, const char* argv[]) {
RenderManager.Present(); RenderManager.Present();
ui.CheckMenuDisplayed(); 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) { if (app.uiGameDefinedDataChangedBitmask != 0) {
void* pData; void* pData;
for (int i = 0; i < XUSER_MAX_COUNT; i++) { for (int i = 0; i < XUSER_MAX_COUNT; i++) {
@ -856,9 +853,7 @@ int main(int argc, const char* argv[]) {
app.uiGameDefinedDataChangedBitmask = 0; app.uiGameDefinedDataChangedBitmask = 0;
} }
g_NetworkManager.DoWork();
g_NetworkManager.DoWork();
// Any threading type things to deal with from the xui side? // Any threading type things to deal with from the xui side?
app.HandleXuiActions(); app.HandleXuiActions();

View file

@ -8,7 +8,6 @@
#include "Minecraft.Client/Linux/Linux_App.h" #include "Minecraft.Client/Linux/Linux_App.h"
#include "Minecraft.Client/Linux/Iggy/gdraw/gdraw.h" #include "Minecraft.Client/Linux/Iggy/gdraw/gdraw.h"
ConsoleUIController ui; ConsoleUIController ui;
static void restoreFixedFunctionStateAfterIggy() { static void restoreFixedFunctionStateAfterIggy() {

View file

@ -1,8 +1,6 @@
// Minecraft.cpp : Defines the entry point for the application. // Minecraft.cpp : Defines the entry point for the application.
// //
#include <assert.h> #include <assert.h>
#include <mutex> #include <mutex>
#include "minecraft/server/MinecraftServer.h" #include "minecraft/server/MinecraftServer.h"
@ -564,7 +562,7 @@ int32_t InitDevice() {
uint32_t numFeatureLevels = ARRAYSIZE(featureLevels); uint32_t numFeatureLevels = ARRAYSIZE(featureLevels);
DXGI_SWAP_CHAIN_DESC sd; DXGI_SWAP_CHAIN_DESC sd;
memset(&sd, 0, sizeof(sd)); memset(&sd, 0, sizeof(sd));
sd.BufferCount = 1; sd.BufferCount = 1;
sd.BufferDesc.Width = width; sd.BufferDesc.Width = width;
sd.BufferDesc.Height = height; sd.BufferDesc.Height = height;
@ -789,25 +787,21 @@ int APIENTRY _tWinMain(_In_ HINSTANCE hInstance,
// } // }
app.UpdateTime(); app.UpdateTime();
InputManager.Tick(); InputManager.Tick();
// ProfileManager.Tick(); // ProfileManager.Tick();
StorageManager.Tick(); StorageManager.Tick();
RenderManager.Tick();
RenderManager.Tick();
// Tick the social networking manager. // Tick the social networking manager.
// CSocialManager::Instance()->Tick(); // CSocialManager::Instance()->Tick();
// Tick sentient. // Tick sentient.
// SentientManager.Tick(); // SentientManager.Tick();
// g_NetworkManager.DoWork();
// g_NetworkManager.DoWork();
// LeaderboardManager::Instance()->Tick(); // LeaderboardManager::Instance()->Tick();
// Render game graphics. // Render game graphics.

View file

@ -97,11 +97,9 @@ void ConsoleUIController::render() {
void ConsoleUIController::beginIggyCustomDraw4J( void ConsoleUIController::beginIggyCustomDraw4J(
IggyCustomDrawCallbackRegion* region, CustomDrawData* customDrawRegion) { 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 // state to a normal state
gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat); gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat);
} }
CustomDrawData* ConsoleUIController::setupCustomDraw( CustomDrawData* ConsoleUIController::setupCustomDraw(
@ -112,7 +110,7 @@ CustomDrawData* ConsoleUIController::setupCustomDraw(
customDrawRegion->y0 = region->y0; customDrawRegion->y0 = region->y0;
customDrawRegion->y1 = region->y1; 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 // state to a normal state
gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat); gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat);
@ -138,7 +136,6 @@ void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion* region) {
endCustomDrawGameStateAndMatrices(); endCustomDrawGameStateAndMatrices();
gdraw_D3D11_EndCustomDraw(region); gdraw_D3D11_EndCustomDraw(region);
} }
void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) { void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) {

View file

@ -38,7 +38,7 @@ public:
pAttributes[i].ValueLen); pAttributes[i].ValueLen);
} else if (_wcsicmp(wAttName, L"xuid") == 0) { } else if (_wcsicmp(wAttName, L"xuid") == 0) {
if (pAttributes[i].ValueLen <= 32) { 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, wcsncpy_s(wTemp, pAttributes[i].strValue,
pAttributes[i].ValueLen); pAttributes[i].ValueLen);
xuid = _wcstoui64(wTemp, nullptr, 10); xuid = _wcstoui64(wTemp, nullptr, 10);
@ -203,7 +203,7 @@ public:
pAttributes[i].NameLen); pAttributes[i].NameLen);
if (_wcsicmp(wAttName, L"SortIndex") == 0) { if (_wcsicmp(wAttName, L"SortIndex") == 0) {
if (pAttributes[i].ValueLen <= 32) { 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, wcsncpy_s(wTemp, pAttributes[i].strValue,
pAttributes[i].ValueLen); pAttributes[i].ValueLen);
uiSortIndex = wcstoul(wTemp, nullptr, 16); uiSortIndex = wcstoul(wTemp, nullptr, 16);
@ -215,14 +215,14 @@ public:
} }
} else if (_wcsicmp(wAttName, L"Full") == 0) { } else if (_wcsicmp(wAttName, L"Full") == 0) {
if (pAttributes[i].ValueLen <= 32) { 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, wcsncpy_s(wTemp, pAttributes[i].strValue,
pAttributes[i].ValueLen); pAttributes[i].ValueLen);
ullFull = _wcstoui64(wTemp, nullptr, 16); ullFull = _wcstoui64(wTemp, nullptr, 16);
} }
} else if (_wcsicmp(wAttName, L"Trial") == 0) { } else if (_wcsicmp(wAttName, L"Trial") == 0) {
if (pAttributes[i].ValueLen <= 32) { 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, wcsncpy_s(wTemp, pAttributes[i].strValue,
pAttributes[i].ValueLen); pAttributes[i].ValueLen);
ullTrial = _wcstoui64(wTemp, nullptr, 16); ullTrial = _wcstoui64(wTemp, nullptr, 16);

View file

@ -26,10 +26,11 @@ public:
int getWidth(); int getWidth();
int getHeight(); int getHeight();
void getRGB(int startX, int startY, int w, int h, std::vector<int>& out, int offset, void getRGB(int startX, int startY, int w, int h, std::vector<int>& out,
int scansize, int level = 0); // 4J Added level param int offset, int scansize,
int* getData(); // 4J added int level = 0); // 4J Added level param
int* getData(int level); // 4J added int* getData(); // 4J added
int* getData(int level); // 4J added
Graphics* getGraphics(); Graphics* getGraphics();
int getTransparency(); int getTransparency();
BufferedImage* getSubimage(int x, int y, int w, int h); BufferedImage* getSubimage(int x, int y, int w, int h);

View file

@ -68,10 +68,7 @@ public:
typedef void* XMEMDECOMPRESSION_CONTEXT; typedef void* XMEMDECOMPRESSION_CONTEXT;
typedef void* XMEMCOMPRESSION_CONTEXT; typedef void* XMEMCOMPRESSION_CONTEXT;
enum XMEMCODEC_TYPE { enum XMEMCODEC_TYPE { XMEMCODEC_DEFAULT = 0, XMEMCODEC_LZX = 1 };
XMEMCODEC_DEFAULT = 0,
XMEMCODEC_LZX = 1
};
int32_t XMemDecompress(XMEMDECOMPRESSION_CONTEXT Context, void* pDestination, int32_t XMemDecompress(XMEMDECOMPRESSION_CONTEXT Context, void* pDestination,
size_t* pDestSize, void* pSource, size_t SrcSize); size_t* pDestSize, void* pSource, size_t SrcSize);

View file

@ -88,7 +88,7 @@ BufferedImage::BufferedImage(const std::wstring& File,
} }
D3DXIMAGE_INFO ImageInfo; D3DXIMAGE_INFO ImageInfo;
memset(&ImageInfo, 0, sizeof(D3DXIMAGE_INFO)); memset(&ImageInfo, 0, sizeof(D3DXIMAGE_INFO));
if (foundOnDisk) { if (foundOnDisk) {
hr = RenderManager.LoadTextureData(wstringtofilename(finalPath), hr = RenderManager.LoadTextureData(wstringtofilename(finalPath),
@ -164,7 +164,7 @@ BufferedImage::BufferedImage(std::uint8_t* pbData, std::uint32_t dataBytes) {
} }
D3DXIMAGE_INFO ImageInfo; D3DXIMAGE_INFO ImageInfo;
memset(&ImageInfo, 0, sizeof(D3DXIMAGE_INFO)); memset(&ImageInfo, 0, sizeof(D3DXIMAGE_INFO));
int32_t hr = int32_t hr =
RenderManager.LoadTextureData(pbData, dataBytes, &ImageInfo, &data[0]); RenderManager.LoadTextureData(pbData, dataBytes, &ImageInfo, &data[0]);
@ -186,8 +186,9 @@ int BufferedImage::getWidth() { return width; }
int BufferedImage::getHeight() { return height; } int BufferedImage::getHeight() { return height; }
void BufferedImage::getRGB(int startX, int startY, int w, int h, std::vector<int>& out, void BufferedImage::getRGB(int startX, int startY, int w, int h,
int offset, int scansize, int level) { std::vector<int>& out, int offset, int scansize,
int level) {
int ww = width >> level; int ww = width >> level;
for (int y = 0; y < h; y++) { for (int y = 0; y < h; y++) {
for (int x = 0; x < w; x++) { 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); BufferedImage* img = new BufferedImage(w, h, 0);
// 4jcraft: Copy pixel data directly into img->data[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 // The old arrayWithLength.h (custom vector impl) was a non-owning wrapper,
// so we write to the raw array directly instead. // std::vector copies so we write to the raw array directly instead.
int srcW = width; int srcW = width;
for (int row = 0; row < h; row++) { for (int row = 0; row < h; row++) {
for (int col = 0; col < w; col++) { for (int col = 0; col < w; col++) {
img->data[0][row * w + col] = img->data[0][row * w + col] = data[0][(y + row) * srcW + (x + col)];
data[0][(y + row) * srcW + (x + col)];
} }
} }

View file

@ -25,14 +25,14 @@ inline std::int64_t QueryPerformanceCounter() {
// Ticks per second for the high-resolution counter. // Ticks per second for the high-resolution counter.
inline std::int64_t QueryPerformanceFrequency() { inline std::int64_t QueryPerformanceFrequency() {
return static_cast<std::int64_t>(std::chrono::steady_clock::period::den) return static_cast<std::int64_t>(std::chrono::steady_clock::period::den) /
/ static_cast<std::int64_t>(std::chrono::steady_clock::period::num); static_cast<std::int64_t>(std::chrono::steady_clock::period::num);
} }
// Elapsed seconds between two counter values. // Elapsed seconds between two counter values.
inline double ElapsedSeconds(std::int64_t start, std::int64_t end) { inline double ElapsedSeconds(std::int64_t start, std::int64_t end) {
return static_cast<double>(end - start) return static_cast<double>(end - start) /
/ static_cast<double>(QueryPerformanceFrequency()); static_cast<double>(QueryPerformanceFrequency());
} }
} // namespace PlatformTime } // namespace PlatformTime

View file

@ -15,5 +15,5 @@ void PerformanceTimer::PrintElapsedTime(const std::wstring& description) {
std::chrono::steady_clock::now() - m_startTime; std::chrono::steady_clock::now() - m_startTime;
fprintf(stderr, "TIMER: %ls: Elapsed time %f\n", description.c_str(), fprintf(stderr, "TIMER: %ls: Elapsed time %f\n", description.c_str(),
elapsedTime.count()); elapsedTime.count());
} }

View file

@ -64,7 +64,7 @@ int32_t Compression::CompressLZXRLE(void* pDestination, unsigned int* pDestSize,
// 0 - 254 - encodes a single byte // 0 - 254 - encodes a single byte
// 255 followed by 0, 1, 2 - encodes a 1, 2, or 3 255s // 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 // 255 followed by 3-255, followed by a byte - encodes a run of n + 1 bytes
do { do {
unsigned char thisOne = *pucIn++; unsigned char thisOne = *pucIn++;
unsigned int count = 1; unsigned int count = 1;
@ -90,8 +90,7 @@ int32_t Compression::CompressLZXRLE(void* pDestination, unsigned int* pDestSize,
} while (pucIn != pucEnd); } while (pucIn != pucEnd);
unsigned int rleSize = (unsigned int)(pucOut - rleCompressBuf); 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); // printf("Compressed from %d to %d to %d\n",SrcSize,rleSize,*pDestSize);
@ -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 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 // 255 followed by 3-255, followed by a byte - encodes a run of n + 1
// bytes // bytes
do { do {
unsigned char thisOne = *pucIn++; unsigned char thisOne = *pucIn++;
unsigned int count = 1; unsigned int count = 1;
@ -139,7 +138,6 @@ int32_t Compression::CompressRLE(void* pDestination, unsigned int* pDestSize,
} }
} while (pucIn != pucEnd); } while (pucIn != pucEnd);
rleSize = (unsigned int)(pucOut - rleCompressBuf); rleSize = (unsigned int)(pucOut - rleCompressBuf);
} }
// Return // Return

View file

@ -8,32 +8,32 @@ class Biome;
class Arrays { class Arrays {
public: public:
static void fill(std::vector<double>& arr, unsigned int from, unsigned int to, static void fill(std::vector<double>& arr, unsigned int from,
double value) { unsigned int to, double value) {
assert(from >= 0); assert(from >= 0);
assert(from <= to); assert(from <= to);
assert(to <= arr.size()); assert(to <= arr.size());
std::fill(arr.data() + from, arr.data() + to, value); std::fill(arr.data() + from, arr.data() + to, value);
} }
static void fill(std::vector<float>& arr, unsigned int from, unsigned int to, static void fill(std::vector<float>& arr, unsigned int from,
float value) { unsigned int to, float value) {
assert(from >= 0); assert(from >= 0);
assert(from <= to); assert(from <= to);
assert(to <= arr.size()); assert(to <= arr.size());
std::fill(arr.data() + from, arr.data() + to, value); std::fill(arr.data() + from, arr.data() + to, value);
} }
static void fill(std::vector<Biome*>& arr, unsigned int from, unsigned int to, static void fill(std::vector<Biome*>& arr, unsigned int from,
Biome* value) { unsigned int to, Biome* value) {
assert(from >= 0); assert(from >= 0);
assert(from <= to); assert(from <= to);
assert(to <= arr.size()); assert(to <= arr.size());
std::fill(arr.data() + from, arr.data() + to, value); std::fill(arr.data() + from, arr.data() + to, value);
} }
static void fill(std::vector<uint8_t>& arr, unsigned int from, unsigned int to, static void fill(std::vector<uint8_t>& arr, unsigned int from,
uint8_t value) { unsigned int to, uint8_t value) {
assert(from >= 0); assert(from >= 0);
assert(from <= to); assert(from <= to);
assert(to <= arr.size()); assert(to <= arr.size());

View file

@ -4,7 +4,7 @@
#include <vector> #include <vector>
#include "Buffer.h" #include "Buffer.h"
#include "console_helpers/Definitions.h" // 4jcraft TODO #include "console_helpers/Definitions.h" // 4jcraft TODO
class IntBuffer; class IntBuffer;
class FloatBuffer; class FloatBuffer;

View file

@ -12,8 +12,8 @@ private:
OutputStream* stream; OutputStream* stream;
protected: protected:
std::vector<uint8_t> buf; // The internal buffer where data is stored. std::vector<uint8_t> buf; // The internal buffer where data is stored.
unsigned int count; // The number of valid bytes in the buffer. unsigned int count; // The number of valid bytes in the buffer.
public: public:
BufferedOutputStream(OutputStream* out, int size); BufferedOutputStream(OutputStream* out, int size);
@ -21,7 +21,8 @@ public:
virtual void flush(); virtual void flush();
virtual void close(); virtual void close();
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(unsigned int b); virtual void write(unsigned int b);
}; };

View file

@ -8,8 +8,8 @@
class ByteArrayInputStream : public InputStream { class ByteArrayInputStream : public InputStream {
protected: protected:
std::vector<uint8_t> buf; // An array of bytes that was provided by the creator of the std::vector<uint8_t> buf; // An array of bytes that was provided by the
// stream. // creator of the stream.
unsigned int count; // The index one greater than the last valid character unsigned int count; // The index one greater than the last valid character
// in the input stream buffer. // in the input stream buffer.
unsigned int mark; // The currently marked position in the stream. unsigned int mark; // The currently marked position in the stream.
@ -23,7 +23,8 @@ public:
virtual ~ByteArrayInputStream(); virtual ~ByteArrayInputStream();
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual int64_t skip(int64_t n); virtual int64_t skip(int64_t n);

View file

@ -6,8 +6,8 @@
#include <cstdint> #include <cstdint>
class ByteArrayOutputStream : public OutputStream { class ByteArrayOutputStream : public OutputStream {
// Note - when actually implementing, std::vector<uint8_t> will need to grow as data is // Note - when actually implementing, std::vector<uint8_t> will need to grow
// written // as data is written
public: public:
std::vector<uint8_t> buf; // The buffer where data is stored. std::vector<uint8_t> buf; // The buffer where data is stored.
@ -22,7 +22,8 @@ public:
virtual void flush() {} virtual void flush() {}
virtual void write(unsigned int b); virtual void write(unsigned int b);
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual std::vector<uint8_t> toByteArray(); virtual std::vector<uint8_t> toByteArray();

View file

@ -8,7 +8,8 @@ class DataInput {
public: public:
virtual int read() = 0; virtual int read() = 0;
virtual int read(std::vector<uint8_t>& b) = 0; virtual int read(std::vector<uint8_t>& b) = 0;
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) = 0; virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) = 0;
virtual bool readBoolean() = 0; virtual bool readBoolean() = 0;
virtual uint8_t readByte() = 0; virtual uint8_t readByte() = 0;
virtual unsigned char readUnsignedByte() = 0; virtual unsigned char readUnsignedByte() = 0;

View file

@ -16,7 +16,8 @@ public:
DataInputStream(InputStream* in); DataInputStream(InputStream* in);
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual bool readBoolean(); virtual bool readBoolean();
virtual uint8_t readByte(); virtual uint8_t readByte();

View file

@ -23,7 +23,8 @@ public:
virtual void write(unsigned int b); virtual void write(unsigned int b);
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual void writeByte(uint8_t a); virtual void writeByte(uint8_t a);
virtual void writeDouble(double a); virtual void writeDouble(double a);

View file

@ -14,7 +14,8 @@ public:
virtual ~FileInputStream(); virtual ~FileInputStream();
virtual int read(); virtual int read();
virtual int read(std::vector<uint8_t>& b); virtual int read(std::vector<uint8_t>& b);
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual int64_t skip(int64_t n); virtual int64_t skip(int64_t n);

View file

@ -13,7 +13,8 @@ public:
virtual ~FileOutputStream(); virtual ~FileOutputStream();
virtual void write(unsigned int b); virtual void write(unsigned int b);
virtual void write(const std::vector<uint8_t>& b); virtual void write(const std::vector<uint8_t>& b);
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length); virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length);
virtual void close(); virtual void close();
virtual void flush(); virtual void flush();

View file

@ -14,7 +14,8 @@ public:
GZIPInputStream(InputStream* out) : stream(out) {}; GZIPInputStream(InputStream* out) : stream(out) {};
virtual int read() { return stream->read(); }; virtual int read() { return stream->read(); };
virtual int read(std::vector<uint8_t>& b) { return stream->read(b); }; virtual int read(std::vector<uint8_t>& b) { return stream->read(b); };
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) { virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
return stream->read(b, offset, length); return stream->read(b, offset, length);
}; };
virtual void close() { return stream->close(); }; virtual void close() { return stream->close(); };

View file

@ -12,7 +12,8 @@ public:
GZIPOutputStream(OutputStream* out) : stream(out) {}; GZIPOutputStream(OutputStream* out) : stream(out) {};
virtual void write(unsigned int b) { stream->write(b); }; virtual void write(unsigned int b) { stream->write(b); };
virtual void write(const std::vector<uint8_t>& b) { stream->write(b); }; virtual void write(const std::vector<uint8_t>& b) { stream->write(b); };
virtual void write(const std::vector<uint8_t>& b, unsigned int offset, unsigned int length) { virtual void write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) {
stream->write(b, offset, length); stream->write(b, offset, length);
}; };
virtual void close() { stream->close(); }; virtual void close() { stream->close(); };

View file

@ -12,7 +12,8 @@ public:
virtual int read() = 0; virtual int read() = 0;
virtual int read(std::vector<uint8_t>& b) = 0; virtual int read(std::vector<uint8_t>& b) = 0;
virtual int read(std::vector<uint8_t>& b, unsigned int offset, unsigned int length) = 0; virtual int read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) = 0;
virtual void close() = 0; virtual void close() = 0;
virtual int64_t skip(int64_t n) = 0; virtual int64_t skip(int64_t n) = 0;

View file

@ -10,15 +10,15 @@ class Biome;
class Node; class Node;
// 4J Jev, just thought it would be easier this way. // 4J Jev, just thought it would be easier this way.
#define ArrayCopyFunctionDeclaration(x) \ #define ArrayCopyFunctionDeclaration(x) \
static void arraycopy(const std::vector<x>& src, unsigned int srcPos, \ static void arraycopy(const std::vector<x>& src, unsigned int srcPos, \
std::vector<x>* dst, unsigned int dstPos, \ std::vector<x>* dst, unsigned int dstPos, \
unsigned int length); unsigned int length);
#define ArrayCopyFunctionDefinition(x) \ #define ArrayCopyFunctionDefinition(x) \
void System::arraycopy(const std::vector<x>& src, unsigned int srcPos, \ void System::arraycopy(const std::vector<x>& src, unsigned int srcPos, \
std::vector<x>* dst, unsigned int dstPos, \ std::vector<x>* dst, unsigned int dstPos, \
unsigned int length) { \ unsigned int length) { \
arraycopy<x>(src, srcPos, dst, dstPos, length); \ arraycopy<x>(src, srcPos, dst, dstPos, length); \
} }
class System { class System {

View file

@ -393,7 +393,9 @@ ByteBuffer* ByteBuffer::put(std::vector<uint8_t>& inputArray) {
return this; return this;
} }
std::vector<uint8_t> ByteBuffer::array() { return std::vector<uint8_t>(buffer, buffer + m_capacity); } std::vector<uint8_t> ByteBuffer::array() {
return std::vector<uint8_t>(buffer, buffer + m_capacity);
}
// Creates a view of this byte buffer as an int buffer. // 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. // The content of the new buffer will start at this buffer's current position.

View file

@ -9,8 +9,8 @@
#include "java/FileFilter.h" #include "java/FileFilter.h"
#include "java/File.h" #include "java/File.h"
#include "console_helpers/PathHelper.h" // 4jcraft TODO #include "console_helpers/PathHelper.h" // 4jcraft TODO
#include "console_helpers/StringHelpers.h" // 4jcraft TODO #include "console_helpers/StringHelpers.h" // 4jcraft TODO
const wchar_t File::pathSeparator = L'/'; const wchar_t File::pathSeparator = L'/';

View file

@ -25,8 +25,8 @@ BufferedOutputStream::~BufferedOutputStream() {
void BufferedOutputStream::flush() { void BufferedOutputStream::flush() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"BufferedOutputStream::flush() called but underlying stream is " "BufferedOutputStream::flush() called but underlying stream is "
"nullptr\n"); "nullptr\n");
return; return;
} }
@ -43,8 +43,8 @@ void BufferedOutputStream::close() {
flush(); flush();
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"BufferedOutputStream::close() called but underlying stream is " "BufferedOutputStream::close() called but underlying stream is "
"nullptr\n"); "nullptr\n");
return; return;
} }
stream->close(); stream->close();
@ -64,8 +64,8 @@ void BufferedOutputStream::close() {
// b - the data. // b - the data.
// off - the start offset in the data. // off - the start offset in the data.
// len - the number of bytes to write. // len - the number of bytes to write.
void BufferedOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset, void BufferedOutputStream::write(const std::vector<uint8_t>& b,
unsigned int length) { unsigned int offset, unsigned int length) {
// Over the length of what we can store in our buffer - just flush the // Over the length of what we can store in our buffer - just flush the
// buffer and output directly // buffer and output directly
if (length >= buf.size()) { if (length >= buf.size()) {
@ -84,7 +84,9 @@ void BufferedOutputStream::write(const std::vector<uint8_t>& b, unsigned int off
// //
// Note that this method does not call the one-argument write method of its // Note that this method does not call the one-argument write method of its
// underlying stream with the single argument b. // underlying stream with the single argument b.
void BufferedOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); } void BufferedOutputStream::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size());
}
// Writes the specified byte to this buffered output stream. // Writes the specified byte to this buffered output stream.
// Overrides: // Overrides:

View file

@ -12,9 +12,12 @@
#include "java/InputOutputStream/ByteArrayInputStream.h" #include "java/InputOutputStream/ByteArrayInputStream.h"
ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf, unsigned int offset, ByteArrayInputStream::ByteArrayInputStream(std::vector<uint8_t>& buf,
unsigned int offset,
unsigned int length) 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; this->buf = buf;
} }
@ -59,7 +62,9 @@ int ByteArrayInputStream::read() {
// Returns: // Returns:
// the total number of bytes read into the buffer, or -1 is there is no more // 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. // data because the end of the stream has been reached.
int ByteArrayInputStream::read(std::vector<uint8_t>& b) { return read(b, 0, b.size()); } int ByteArrayInputStream::read(std::vector<uint8_t>& b) {
return read(b, 0, b.size());
}
// Reads up to len bytes of data into an array of bytes from this input stream. // 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, // 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; return k;
} }
ByteArrayInputStream::~ByteArrayInputStream() { ByteArrayInputStream::~ByteArrayInputStream() {}
}

View file

@ -18,8 +18,7 @@ ByteArrayOutputStream::ByteArrayOutputStream(unsigned int size) {
buf = std::vector<uint8_t>(size); buf = std::vector<uint8_t>(size);
} }
ByteArrayOutputStream::~ByteArrayOutputStream() { ByteArrayOutputStream::~ByteArrayOutputStream() {}
}
// Writes the specified byte to this byte array output stream. // Writes the specified byte to this byte array output stream.
// Parameters: // Parameters:
@ -35,18 +34,21 @@ void ByteArrayOutputStream::write(unsigned int b) {
// Writes b.size() bytes from the specified byte array to this output stream. // 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 // The general contract for write(b) is that it should have exactly the same
// effect as the call write(b, 0, b.size()). // effect as the call write(b, 0, b.size()).
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); } void ByteArrayOutputStream::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size());
}
// Writes len bytes from the specified byte array starting at offset off to this // 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 // byte array output stream. Parameters: b - the data. off - the start offset in
// the data. len - the number of bytes to write. // the data. len - the number of bytes to write.
void ByteArrayOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset, void ByteArrayOutputStream::write(const std::vector<uint8_t>& b,
unsigned int length) { unsigned int offset, unsigned int length) {
assert(b.size() >= offset + length); assert(b.size() >= offset + length);
// If we will fill the buffer we need to make it bigger // If we will fill the buffer we need to make it bigger
if (count + length >= buf.size()) 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::memcpy(&buf[count], &b[offset], length);
// std::copy( b->data+offset, b->data+offset+length, buf->data + count ); // // std::copy( b->data+offset, b->data+offset+length, buf->data + count ); //

View file

@ -21,8 +21,8 @@ DataInputStream::DataInputStream(InputStream* in) : stream(in) {}
int DataInputStream::read() { int DataInputStream::read() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::read() called but underlying stream is " "DataInputStream::read() called but underlying stream is "
"nullptr\n"); "nullptr\n");
return -1; return -1;
} }
return stream->read(); return stream->read();
@ -56,8 +56,9 @@ int DataInputStream::read() {
int DataInputStream::read(std::vector<uint8_t>& b) { int DataInputStream::read(std::vector<uint8_t>& b) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::read(std::vector<uint8_t>) called but underlying stream is " "DataInputStream::read(std::vector<uint8_t>) called but "
"nullptr\n"); "underlying stream is "
"nullptr\n");
return -1; return -1;
} }
return read(b, 0, b.size()); return read(b, 0, b.size());
@ -96,8 +97,9 @@ int DataInputStream::read(std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) { unsigned int length) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::read(std::vector<uint8_t>,offset,length) called but " "DataInputStream::read(std::vector<uint8_t>,offset,length) "
"underlying stream is nullptr\n"); "called but "
"underlying stream is nullptr\n");
return -1; return -1;
} }
return stream->read(b, offset, length); return stream->read(b, offset, length);
@ -108,8 +110,8 @@ int DataInputStream::read(std::vector<uint8_t>& b, unsigned int offset,
void DataInputStream::close() { void DataInputStream::close() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::close() called but underlying stream is " "DataInputStream::close() called but underlying stream is "
"nullptr\n"); "nullptr\n");
return; return;
} }
stream->close(); stream->close();
@ -121,8 +123,8 @@ void DataInputStream::close() {
bool DataInputStream::readBoolean() { bool DataInputStream::readBoolean() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::readBoolean() but underlying stream is " "DataInputStream::readBoolean() but underlying stream is "
"nullptr\n"); "nullptr\n");
return false; return false;
} }
return stream->read() != 0; return stream->read() != 0;
@ -134,7 +136,8 @@ bool DataInputStream::readBoolean() {
// the 8-bit value read. // the 8-bit value read.
uint8_t DataInputStream::readByte() { uint8_t DataInputStream::readByte() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readByte() but underlying stream is nullptr\n"); "DataInputStream::readByte() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -144,8 +147,8 @@ uint8_t DataInputStream::readByte() {
unsigned char DataInputStream::readUnsignedByte() { unsigned char DataInputStream::readUnsignedByte() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::readUnsignedByte() but underlying stream is " "DataInputStream::readUnsignedByte() but underlying stream is "
"nullptr\n"); "nullptr\n");
return 0; return 0;
} }
return (unsigned char)stream->read(); return (unsigned char)stream->read();
@ -159,7 +162,8 @@ unsigned char DataInputStream::readUnsignedByte() {
// interface DataOutput. Returns: the char value read. // interface DataOutput. Returns: the char value read.
wchar_t DataInputStream::readChar() { wchar_t DataInputStream::readChar() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readChar() but underlying stream is nullptr\n"); "DataInputStream::readChar() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -190,8 +194,9 @@ bool DataInputStream::readFully(std::vector<uint8_t>& b) {
// InputStreams // InputStreams
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::readFully(std::vector<uint8_t>) but underlying stream is " "DataInputStream::readFully(std::vector<uint8_t>) but "
"nullptr\n"); "underlying stream is "
"nullptr\n");
return false; return false;
} }
for (unsigned int i = 0; i < b.size(); i++) { for (unsigned int i = 0; i < b.size(); i++) {
@ -212,8 +217,9 @@ bool DataInputStream::readFully(std::vector<char>& b) {
// InputStreams // InputStreams
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::readFully(std::vector<char>) but underlying stream is " "DataInputStream::readFully(std::vector<char>) but underlying "
"nullptr\n"); "stream is "
"nullptr\n");
return false; return false;
} }
for (unsigned int i = 0; i < b.size(); i++) { for (unsigned int i = 0; i < b.size(); i++) {
@ -260,7 +266,8 @@ float DataInputStream::readFloat() {
// interface DataOutput. Returns: the int value read. // interface DataOutput. Returns: the int value read.
int DataInputStream::readInt() { int DataInputStream::readInt() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readInt() but underlying stream is nullptr\n"); "DataInputStream::readInt() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -292,7 +299,8 @@ int DataInputStream::readInt() {
// the long value read. // the long value read.
int64_t DataInputStream::readLong() { int64_t DataInputStream::readLong() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readLong() but underlying stream is nullptr\n"); "DataInputStream::readLong() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -321,7 +329,8 @@ int64_t DataInputStream::readLong() {
// method of interface DataOutput. Returns: the 16-bit value read. // method of interface DataOutput. Returns: the 16-bit value read.
short DataInputStream::readShort() { short DataInputStream::readShort() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readShort() but underlying stream is nullptr\n"); "DataInputStream::readShort() but underlying stream is nullptr\n");
return 0; return 0;
} }
@ -333,8 +342,8 @@ short DataInputStream::readShort() {
unsigned short DataInputStream::readUnsignedShort() { unsigned short DataInputStream::readUnsignedShort() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::readUnsignedShort() but underlying stream is " "DataInputStream::readUnsignedShort() but underlying stream is "
"nullptr\n"); "nullptr\n");
return 0; return 0;
} }
int a = stream->read(); int a = stream->read();
@ -391,7 +400,8 @@ unsigned short DataInputStream::readUnsignedShort() {
std::wstring DataInputStream::readUTF() { std::wstring DataInputStream::readUTF() {
std::wstring outputString; std::wstring outputString;
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataInputStream::readUTF() but underlying stream is nullptr\n"); "DataInputStream::readUTF() but underlying stream is nullptr\n");
return outputString; return outputString;
} }
@ -519,8 +529,8 @@ int DataInputStream::readUTFChar() {
int returnValue = -1; int returnValue = -1;
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataInputStream::readUTFChar() but underlying stream is " "DataInputStream::readUTFChar() but underlying stream is "
"nullptr\n"); "nullptr\n");
return returnValue; return returnValue;
} }
int firstByte = stream->read(); int firstByte = stream->read();

View file

@ -25,8 +25,8 @@ void DataOutputStream::deleteChildStream() { delete stream; }
void DataOutputStream::write(unsigned int b) { void DataOutputStream::write(unsigned int b) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataOutputStream::write(unsigned int) called but underlying " "DataOutputStream::write(unsigned int) called but underlying "
"stream is nullptr\n"); "stream is nullptr\n");
return; return;
} }
stream->write(b); stream->write(b);
@ -37,8 +37,8 @@ void DataOutputStream::write(unsigned int b) {
void DataOutputStream::flush() { void DataOutputStream::flush() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataOutputStream::flush() called but underlying stream is " "DataOutputStream::flush() called but underlying stream is "
"nullptr\n"); "nullptr\n");
return; return;
} }
stream->flush(); stream->flush();
@ -47,7 +47,9 @@ void DataOutputStream::flush() {
// Writes b.size() bytes from the specified byte array to this output stream. // 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 // 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. // effect as the call write(b, 0, b.size()). Parameters: b - the data.
void DataOutputStream::write(const std::vector<uint8_t>& b) { write(b, 0, b.size()); } void DataOutputStream::write(const std::vector<uint8_t>& b) {
write(b, 0, b.size());
}
// Writes len bytes from the specified byte array starting at offset off to the // 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 // underlying output stream. If no exception is thrown, the counter written is
@ -57,8 +59,9 @@ void DataOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
unsigned int length) { unsigned int length) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataOutputStream::write(std::vector<uint8_t>,...) called but underlying " "DataOutputStream::write(std::vector<uint8_t>,...) called but "
"stream is nullptr\n"); "underlying "
"stream is nullptr\n");
return; return;
} }
stream->write(b, offset, length); stream->write(b, offset, length);
@ -72,8 +75,8 @@ void DataOutputStream::write(const std::vector<uint8_t>& b, unsigned int offset,
void DataOutputStream::close() { void DataOutputStream::close() {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(stderr,
"DataOutputStream::close() called but underlying stream is " "DataOutputStream::close() called but underlying stream is "
"nullptr\n"); "nullptr\n");
return; return;
} }
stream->close(); stream->close();
@ -154,7 +157,8 @@ void DataOutputStream::writeShort(short a) {
void DataOutputStream::writeUnsignedShort(unsigned short a) { void DataOutputStream::writeUnsignedShort(unsigned short a) {
if (stream == nullptr) { if (stream == nullptr) {
fprintf(stderr, fprintf(
stderr,
"DataOutputStream::writeUnsignedShort() but underlying stream is " "DataOutputStream::writeUnsignedShort() but underlying stream is "
"nullptr\n"); "nullptr\n");
return; return;
@ -258,4 +262,6 @@ void DataOutputStream::writeUTF(const std::wstring& str) {
} }
// 4J Added // 4J Added
void DataOutputStream::writePlayerUID(unsigned long long player) { writeLong(player); } void DataOutputStream::writePlayerUID(unsigned long long player) {
writeLong(player);
}

View file

@ -5,7 +5,7 @@
#include "java/File.h" #include "java/File.h"
#include "java/InputOutputStream/FileOutputStream.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 // Creates a file output stream to write to the file represented by the
// specified File object. A new FileDescriptor object is created to represent // specified File object. A new FileDescriptor object is created to represent

View file

@ -1017,8 +1017,7 @@ void Minecraft::run_middle() {
// } // }
// 4J-PB - AUTOSAVE TIMER - if the player is the host // 4J-PB - AUTOSAVE TIMER - if the player is the host
if (level != nullptr && if (level != nullptr && g_NetworkManager.IsHost()) {
g_NetworkManager.IsHost()) {
/*if(!bAutosaveTimerSet) /*if(!bAutosaveTimerSet)
{ {
// set the timer // set the timer
@ -1086,8 +1085,10 @@ void Minecraft::run_middle() {
#if !defined(_CONTENT_PACKAGE) #if !defined(_CONTENT_PACKAGE)
{ {
// print the time // print the time
auto now_tp = std::chrono::system_clock::now(); auto now_tp = std::chrono::
std::time_t now_tt = std::chrono::system_clock::to_time_t(now_tp); system_clock::now();
std::time_t now_tt = std::chrono::
system_clock::to_time_t(now_tp);
std::tm utcTime{}; std::tm utcTime{};
#if defined(_WIN32) #if defined(_WIN32)
gmtime_s(&utcTime, &now_tt); gmtime_s(&utcTime, &now_tt);
@ -1577,16 +1578,12 @@ void Minecraft::run_middle() {
// if (pause) timer.a = 1; // if (pause) timer.a = 1;
soundEngine->tick((std::shared_ptr<Mob>*)localplayers, soundEngine->tick((std::shared_ptr<Mob>*)localplayers,
timer->a); timer->a);
// if (level != nullptr) level->updateLights(); // if (level != nullptr) level->updateLights();
glEnable(GL_TEXTURE_2D); glEnable(GL_TEXTURE_2D);
// if (!Keyboard::isKeyDown(Keyboard.KEY_F7)) // if (!Keyboard::isKeyDown(Keyboard.KEY_F7))
// Display.update(); // 4J - removed // Display.update(); // 4J - removed
@ -1607,7 +1604,6 @@ void Minecraft::run_middle() {
gameRenderer->render(timer->a, bFirst); gameRenderer->render(timer->a, bFirst);
bFirst = false; bFirst = false;
if (i == iPrimaryPad) { if (i == iPrimaryPad) {
// check to see if we need to capture a // check to see if we need to capture a
// screenshot for the save game thumbnail // screenshot for the save game thumbnail
@ -1694,17 +1690,15 @@ void Minecraft::run_middle() {
achievementPopup->render(); 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. // portable thread yield.
// std::this_thread::sleep_for( // std::this_thread::sleep_for(
// std::chrono::milliseconds(0)); // 4J - was // std::chrono::milliseconds(0)); // 4J - was
// Thread.yield()) // Thread.yield())
// if (Keyboard::isKeyDown(Keyboard::KEY_F7)) // if (Keyboard::isKeyDown(Keyboard::KEY_F7))
// Display.update(); // 4J - removed condition // Display.update(); // 4J - removed condition
Display::update(); Display::update();
// checkScreenshot(); // 4J - removed // checkScreenshot(); // 4J - removed
@ -1980,8 +1974,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
glBindTexture(GL_TEXTURE_2D, glBindTexture(GL_TEXTURE_2D,
textures->loadTexture(TN_TERRAIN)); // L"/terrain.png")); textures->loadTexture(TN_TERRAIN)); // L"/terrain.png"));
if (bFirst) { 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; 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 // 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 // player that is actually in that level happens to be active. This is
@ -3535,7 +3527,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
levelsTickedFlags = 0; levelsTickedFlags = 0;
#if !defined(DISABLE_LEVELTICK_THREAD) #if !defined(DISABLE_LEVELTICK_THREAD)
levelTickEventQueue->waitForFinish(); levelTickEventQueue->waitForFinish();
#endif #endif
SparseLightStorage::tick(); // 4J added SparseLightStorage::tick(); // 4J added
@ -3562,7 +3554,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
// level this frame // level this frame
levelsTickedFlags |= (1 << i); levelsTickedFlags |= (1 << i);
if (!pause) levelRenderer->tick(); if (!pause) levelRenderer->tick();
// if (!pause && player!=null) { // if (!pause && player!=null) {
// if (player != null && !level.entities.contains(player)) { // if (player != null && !level.entities.contains(player)) {
@ -3572,8 +3564,7 @@ void Minecraft::tick(bool bFirst, bool bUpdateTextures) {
if (levels[i] != nullptr) { if (levels[i] != nullptr) {
if (!pause) { if (!pause) {
if (levels[i]->skyFlashTime > 0) levels[i]->skyFlashTime--; if (levels[i]->skyFlashTime > 0) levels[i]->skyFlashTime--;
levels[i]->tickEntities(); levels[i]->tickEntities();
} }
// optimisation to set the culling off early, in parallel with // 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 - // app.DebugPrintf("Minecraft::tick spawn settings -
// Difficulty = %d",options->difficulty); // Difficulty = %d",options->difficulty);
levels[i]->setSpawnSettings(level->difficulty > 0, true); levels[i]->setSpawnSettings(level->difficulty > 0, true);
#if defined(DISABLE_LEVELTICK_THREAD) #if defined(DISABLE_LEVELTICK_THREAD)
levels[i]->tick(); levels[i]->tick();
#else #else
levelTickEventQueue->sendEvent(levels[i]); levelTickEventQueue->sendEvent(levels[i]);
#endif #endif
} }
} }
} }
if (bFirst) { if (bFirst) {
if (!pause) particleEngine->tick(); if (!pause) particleEngine->tick();
} }
// 4J Stu - Keep ticking the connections if paused so that they don't // 4J Stu - Keep ticking the connections if paused so that they don't

View file

@ -252,7 +252,7 @@ void Minimap::render(std::shared_ptr<Player> player, Textures* textures,
// DCR: Render the players current position here instead // DCR: Render the players current position here instead
if (player != nullptr) { if (player != nullptr) {
wchar_t playerPosText[32]; wchar_t playerPosText[32];
memset(&playerPosText, 0, sizeof(wchar_t) * 32); memset(&playerPosText, 0, sizeof(wchar_t) * 32);
int posx = floor(player->x); int posx = floor(player->x);
int posy = floor(player->y); int posy = floor(player->y);
int posz = floor(player->z); int posz = floor(player->z);

View file

@ -2,7 +2,6 @@
#include <memory> #include <memory>
#include "minecraft/client/gui/inventory/AbstractContainerScreen.h" #include "minecraft/client/gui/inventory/AbstractContainerScreen.h"
#include "minecraft/world/inventory/AnvilMenu.h" #include "minecraft/world/inventory/AnvilMenu.h"
#include "minecraft/world/inventory/net.minecraft.world.inventory.ContainerListener.h" #include "minecraft/world/inventory/net.minecraft.world.inventory.ContainerListener.h"

View file

@ -170,12 +170,12 @@ void BeaconScreen::renderBg(float a) {
// Render payment item icons // Render payment item icons
itemRenderer->renderGuiItem( itemRenderer->renderGuiItem(
font, minecraft->textures, font, minecraft->textures,
std::make_shared<ItemInstance>(Item::emerald_Id, 1, 0), std::make_shared<ItemInstance>(Item::emerald_Id, 1, 0), xo + 42,
xo + 42, yo + 109); yo + 109);
itemRenderer->renderGuiItem( itemRenderer->renderGuiItem(
font, minecraft->textures, font, minecraft->textures,
std::make_shared<ItemInstance>(Item::diamond_Id, 1, 0), std::make_shared<ItemInstance>(Item::diamond_Id, 1, 0), xo + 42 + 22,
xo + 42 + 22, yo + 109); yo + 109);
itemRenderer->renderGuiItem(font, minecraft->textures, itemRenderer->renderGuiItem(font, minecraft->textures,
std::shared_ptr<ItemInstance>( std::shared_ptr<ItemInstance>(
new ItemInstance(Item::goldIngot_Id, 1, 0)), new ItemInstance(Item::goldIngot_Id, 1, 0)),

View file

@ -77,9 +77,9 @@ void BatModel::render(std::shared_ptr<Entity> entity, float time, float r,
body->xRot = std::numbers::pi; body->xRot = std::numbers::pi;
rightWing->xRot = -std::numbers::pi * .05f; rightWing->xRot = -std::numbers::pi * .05f;
rightWing->yRot = -std::numbers::pi * .40f; rightWing->yRot = -std::numbers::pi * .40f;
rightWingTip->yRot = -std::numbers::pi * .55f; rightWingTip->yRot = -std::numbers::pi * .55f;
leftWing->xRot = rightWing->xRot; leftWing->xRot = rightWing->xRot;
leftWing->yRot = -rightWing->yRot; leftWing->yRot = -rightWing->yRot;
leftWingTip->yRot = -rightWingTip->yRot; leftWingTip->yRot = -rightWingTip->yRot;

View file

@ -223,8 +223,10 @@ void HumanoidModel::setupAnim(float time, float r, float bob, float yRot,
arm0->zRot = 0.0f; arm0->zRot = 0.0f;
arm1->zRot = 0.0f; arm1->zRot = 0.0f;
} else if (uiBitmaskOverrideAnim & (1 << eAnim_SingleArms)) { } else if (uiBitmaskOverrideAnim & (1 << eAnim_SingleArms)) {
arm0->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; arm0->xRot =
arm1->xRot = (cosf(time * 0.6662f + std::numbers::pi) * 2.0f) * r * 0.5f; (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; arm0->zRot = 0.0f;
arm1->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 // that's up
else if ((uiBitmaskOverrideAnim & (1 << eAnim_StatueOfLiberty)) && else if ((uiBitmaskOverrideAnim & (1 << eAnim_StatueOfLiberty)) &&
(holdingRightHand == 0) && (attackTime == 0.0f)) { (holdingRightHand == 0) && (attackTime == 0.0f)) {
arm0->xRot = -std::numbers::pi ; arm0->xRot = -std::numbers::pi;
arm0->zRot = -0.3f; arm0->zRot = -0.3f;
arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f; arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f;
arm1->zRot = 0.0f; arm1->zRot = 0.0f;
} else { } 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; arm1->xRot = (cosf(time * 0.6662f) * 2.0f) * r * 0.5f;
arm0->zRot = 0.0f; arm0->zRot = 0.0f;
arm1->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 *= swing;
swing = 1.0f - swing; swing = 1.0f - swing;
float aa = sinf(swing * std::numbers::pi); 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->xRot -= aa * 1.2f + bb; // 4J - changed 1.2 -> 1.2f
arm0->yRot += body->yRot * 2.0f; 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;
is = is * is * is; is = is * is * is;
float iss = 1 - is; float iss = 1 - is;
arm0->xRot = -std::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) * arm0->xRot =
(eating_swing > 0.2 ? 1.0f : 0.0f) * -std::abs(cosf(eating_t / 4.0f * std::numbers::pi) * 0.1f) *
2.0f; // This factor is the chomping bit (conditional (eating_swing > 0.2 ? 1.0f : 0.0f) *
// factor is so that he doesn't eat whilst the 2.0f; // This factor is the chomping bit (conditional
// food is being pulled away at the end) // factor is so that he doesn't eat whilst the
// food is being pulled away at the end)
arm0->yRot -= arm0->yRot -=
iss * 0.5f; // This factor and the following to the general arm iss * 0.5f; // This factor and the following to the general arm
// movement through the life of the swing // movement through the life of the swing

View file

@ -41,7 +41,7 @@ MinecartModel::MinecartModel() : Model() {
cubes[1]->yRot = std::numbers::pi / 2 * 3; cubes[1]->yRot = std::numbers::pi / 2 * 3;
cubes[2]->yRot = std::numbers::pi / 2 * 1; cubes[2]->yRot = std::numbers::pi / 2 * 1;
cubes[3]->yRot = std::numbers::pi / 2 * 2; 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 // 4J added - compile now to avoid random performance hit first time cubes
// are rendered // are rendered

View file

@ -544,8 +544,7 @@ void ModelHorse::prepareMobModel(std::shared_ptr<LivingEntity> mob, float wp,
Leg2B->y = Leg2B->y =
Leg2A->y + Leg2A->y +
(sinf(r90 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * (sinf(r90 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * 7.f);
7.f);
Leg2B->z = Leg2B->z =
Leg2A->z + Leg2A->z +
(cosf(r270 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) * (cosf(r270 + standAngle + iStanding * (legAnim1 * 0.5f * ws)) *
@ -576,14 +575,16 @@ void ModelHorse::prepareMobModel(std::shared_ptr<LivingEntity> mob, float wp,
Leg3A->xRot = rlegRot; Leg3A->xRot = rlegRot;
Leg3B->xRot = 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 + standing +
(legXRotAnim + std::max(0.0f, legAnim1 * 0.5f * ws)) * iStanding; (legXRotAnim + std::max(0.0f, legAnim1 * 0.5f * ws)) * iStanding;
Leg3C->xRot = Leg3B->xRot; Leg3C->xRot = Leg3B->xRot;
Leg4A->xRot = llegRot; Leg4A->xRot = llegRot;
Leg4B->xRot = 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 + standing +
(-legXRotAnim + std::max(0.0f, -legAnim1 * 0.5f * ws)) * iStanding; (-legXRotAnim + std::max(0.0f, -legAnim1 * 0.5f * ws)) * iStanding;
Leg4C->xRot = Leg4B->xRot; Leg4C->xRot = Leg4B->xRot;

View file

@ -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; backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r;
backLegR->xRot = ((float)cosf(time * 0.6662f + 0.3f) * 1.f) * r; backLegR->xRot = ((float)cosf(time * 0.6662f + 0.3f) * 1.f) * r;
frontLegL->xRot = frontLegL->xRot =
((float)cosf(time * 0.6662f + std::numbers::pi + 0.3f) * 1.f) * r; ((float)cosf(time * 0.6662f + std::numbers::pi + 0.3f) * 1.f) *
frontLegR->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; r;
tail2->xRot = 0.55f * std::numbers::pi + 0.1f * std::numbers::pi * cosf(time) * 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 { } else {
backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r; backLegL->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r;
backLegR->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; backLegR->xRot =
frontLegL->xRot = ((float)cosf(time * 0.6662f + std::numbers::pi) * 1.f) * r; ((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; frontLegR->xRot = ((float)cosf(time * 0.6662f) * 1.f) * r;
if (state == WALK_STATE) 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 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<LivingEntity> mob, float time,
tail1->xRot = std::numbers::pi * 0.55f; tail1->xRot = std::numbers::pi * 0.55f;
tail2->xRot = std::numbers::pi * 0.85f; 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->y = frontLegR->y = frontLegY + 2;
frontLegL->z = frontLegR->z = -7; 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->y = backLegR->y = backLegY + 3;
backLegL->z = backLegR->z = backLegZ - 4; backLegL->z = backLegR->z = backLegZ - 4;
state = SITTING_STATE; state = SITTING_STATE;

View file

@ -73,10 +73,10 @@ void SilverfishModel::setupAnim(float time, float r, float bob, float yRot,
std::shared_ptr<Entity> entity, std::shared_ptr<Entity> entity,
unsigned int uiBitmaskOverrideAnim) { unsigned int uiBitmaskOverrideAnim) {
for (unsigned int i = 0; i < bodyParts.size(); i++) { for (unsigned int i = 0; i < bodyParts.size(); i++) {
bodyParts[i]->yRot = cosf(bob * .9f + i * .15f * std::numbers::pi) * std::numbers::pi * .05f * bodyParts[i]->yRot = cosf(bob * .9f + i * .15f * std::numbers::pi) *
(1 + abs((int)i - 2)); std::numbers::pi * .05f * (1 + abs((int)i - 2));
bodyParts[i]->x = bodyParts[i]->x = sinf(bob * .9f + i * .15f * std::numbers::pi) *
sinf(bob * .9f + i * .15f * std::numbers::pi) * std::numbers::pi * .2f * abs((int)i - 2); std::numbers::pi * .2f * abs((int)i - 2);
} }
bodyLayers[0]->yRot = bodyParts[2]->yRot; bodyLayers[0]->yRot = bodyParts[2]->yRot;

View file

@ -120,22 +120,38 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot,
leg7->yRot = +ur * 2.0f - ro; leg7->yRot = +ur * 2.0f - ro;
float c0 = 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 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 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 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 = 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 = 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 = 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 = 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; leg0->yRot += +c0;
leg1->yRot += -c0; leg1->yRot += -c0;

View file

@ -78,7 +78,8 @@ void VillagerModel::setupAnim(float time, float r, float bob, float yRot,
arms->xRot = -0.75f; arms->xRot = -0.75f;
leg0->xRot = ((float)cosf(time * 0.6662f) * 1.4f) * r * 0.5f; 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; leg0->yRot = 0;
leg1->yRot = 0; leg1->yRot = 0;
} }

View file

@ -43,13 +43,14 @@ void VillagerZombieModel::setupAnim(float time, float r, float bob, float yRot,
uiBitmaskOverrideAnim); uiBitmaskOverrideAnim);
float attack2 = sinf(attackTime * std::numbers::pi); 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; arm0->zRot = 0;
arm1->zRot = 0; arm1->zRot = 0;
arm0->yRot = -(0.1f - attack2 * 0.6f); arm0->yRot = -(0.1f - attack2 * 0.6f);
arm1->yRot = +(0.1f - attack2 * 0.6f); arm1->yRot = +(0.1f - attack2 * 0.6f);
arm0->xRot = -std::numbers::pi / 2.0f; arm0->xRot = -std::numbers::pi / 2.0f;
arm1->xRot = -std::numbers::pi / 2.0f; arm1->xRot = -std::numbers::pi / 2.0f;
arm0->xRot -= attack2 * 1.2f - attack * 0.4f; arm0->xRot -= attack2 * 1.2f - attack * 0.4f;
arm1->xRot -= attack2 * 1.2f - attack * 0.4f; arm1->xRot -= attack2 * 1.2f - attack * 0.4f;

View file

@ -62,9 +62,11 @@ void WitchModel::setupAnim(float time, float r, float bob, float yRot,
nose->translateX = nose->translateY = nose->translateZ = 0; nose->translateX = nose->translateY = nose->translateZ = 0;
float speed = 0.01f * (entity->entityId % 10); 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->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) { if (holdingItem) {
nose->xRot = -0.9f; nose->xRot = -0.9f;

View file

@ -73,8 +73,8 @@ void WitherBossModel::prepareMobModel(std::shared_ptr<LivingEntity> mob,
std::dynamic_pointer_cast<WitherBoss>(mob); std::dynamic_pointer_cast<WitherBoss>(mob);
for (int i = 1; i < 3; i++) { for (int i = 1; i < 3; i++) {
heads[i]->yRot = heads[i]->yRot = (boss->getHeadYRot(i - 1) - mob->yBodyRot) /
(boss->getHeadYRot(i - 1) - mob->yBodyRot) / (180 / std::numbers::pi); (180 / std::numbers::pi);
heads[i]->xRot = boss->getHeadXRot(i - 1) / (180 / std::numbers::pi); heads[i]->xRot = boss->getHeadXRot(i - 1) / (180 / std::numbers::pi);
} }
} }

View file

@ -22,7 +22,8 @@ void ZombieModel::setupAnim(float time, float r, float bob, float yRot,
uiBitmaskOverrideAnim); uiBitmaskOverrideAnim);
float attack2 = sinf(attackTime * std::numbers::pi); 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; arm0->zRot = 0;
arm1->zRot = 0; arm1->zRot = 0;
arm0->yRot = -(0.1f - attack2 * 0.6f); arm0->yRot = -(0.1f - attack2 * 0.6f);

View file

@ -135,12 +135,15 @@ void DragonModel::render(std::shared_ptr<Entity> entity, float time, float r,
float rotScale = 1.5f; float rotScale = 1.5f;
double startComponents[3]; double startComponents[3];
std::vector<double> start = std::vector<double>(startComponents, startComponents + 3); std::vector<double> start =
std::vector<double>(startComponents, startComponents + 3);
dragon->getLatencyPos(start, 6, a); dragon->getLatencyPos(start, 6, a);
double latencyPosAComponents[3], latencyPosBComponents[3]; double latencyPosAComponents[3], latencyPosBComponents[3];
std::vector<double> latencyPosA = std::vector<double>(latencyPosAComponents, latencyPosAComponents + 3); std::vector<double> latencyPosA =
std::vector<double> latencyPosB = std::vector<double>(latencyPosBComponents, latencyPosBComponents + 3); std::vector<double>(latencyPosAComponents, latencyPosAComponents + 3);
std::vector<double> latencyPosB =
std::vector<double>(latencyPosBComponents, latencyPosBComponents + 3);
dragon->getLatencyPos(latencyPosA, 5, a); dragon->getLatencyPos(latencyPosA, 5, a);
dragon->getLatencyPos(latencyPosB, 10, a); dragon->getLatencyPos(latencyPosB, 10, a);
float rot2 = rotWrap(latencyPosA[0] - latencyPosB[0]); float rot2 = rotWrap(latencyPosA[0] - latencyPosB[0]);
@ -159,14 +162,16 @@ void DragonModel::render(std::shared_ptr<Entity> entity, float time, float r,
dragon->getLatencyPos(p, 5 - i, a); dragon->getLatencyPos(p, 5 - i, a);
rr = (float)cosf(i * 0.45f + roff) * 0.15f; rr = (float)cosf(i * 0.45f + roff) * 0.15f;
neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) * std::numbers::pi / neck->yRot = rotWrap(dragon->getHeadPartYRotDiff(i, start, p)) *
180.0f * rotScale; // 4J replaced "p[0] - start[0] with std::numbers::pi / 180.0f *
// call to getHeadPartYRotDiff rotScale; // 4J replaced "p[0] - start[0] with
// call to getHeadPartYRotDiff
neck->xRot = rr + (float)(dragon->getHeadPartYOffset(i, start, p)) * neck->xRot = rr + (float)(dragon->getHeadPartYOffset(i, start, p)) *
std::numbers::pi / 180.0f * rotScale * std::numbers::pi / 180.0f * rotScale *
5.0f; // 4J replaced "p[1] - start[1]" with call 5.0f; // 4J replaced "p[1] - start[1]" with call
// to getHeadPartYOffset // 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->y = yy;
neck->z = zz; neck->z = zz;
@ -182,10 +187,11 @@ void DragonModel::render(std::shared_ptr<Entity> entity, float time, float r,
head->x = xx; head->x = xx;
dragon->getLatencyPos(p, 0, a); dragon->getLatencyPos(p, 0, a);
head->yRot = 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 1; // 4J replaced "p[0] - start[0] with call to getHeadPartYRotDiff
head->xRot = (float)(dragon->getHeadPartYOffset(6, start, p)) * std::numbers::pi / head->xRot = (float)(dragon->getHeadPartYOffset(6, start, p)) *
180.0f * rotScale * 5.0f; // 4J Added std::numbers::pi / 180.0f * rotScale * 5.0f; // 4J Added
head->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180 * 1; head->zRot = -rotWrap(p[0] - rot) * std::numbers::pi / 180 * 1;
head->render(scale, usecompiled); head->render(scale, usecompiled);
glPushMatrix(); glPushMatrix();
@ -231,8 +237,10 @@ void DragonModel::render(std::shared_ptr<Entity> entity, float time, float r,
for (int i = 0; i < 12; i++) { for (int i = 0; i < 12; i++) {
dragon->getLatencyPos(p, 12 + i, a); dragon->getLatencyPos(p, 12 + i, a);
rr += sinf(i * 0.45f + roff) * 0.05f; rr += sinf(i * 0.45f + roff) * 0.05f;
neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) * std::numbers::pi / 180; neck->yRot = (rotWrap(p[0] - start[0]) * rotScale + 180) *
neck->xRot = rr + (float)(p[1] - start[1]) * std::numbers::pi / 180 * rotScale * 5; 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->zRot = rotWrap(p[0] - rot) * std::numbers::pi / 180 * rotScale;
neck->y = yy; neck->y = yy;
neck->z = zz; neck->z = zz;

View file

@ -990,7 +990,7 @@ void ClientConnection::handleChunkTilesUpdate(
MultiPlayerLevel* dimensionLevel = MultiPlayerLevel* dimensionLevel =
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx]; (MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
if (dimensionLevel) { if (dimensionLevel) {
LevelChunk* lc = dimensionLevel->getChunk(packet->xc, packet->zc); LevelChunk* lc = dimensionLevel->getChunk(packet->xc, packet->zc);
int xo = packet->xc * 16; int xo = packet->xc * 16;
int zo = packet->zc * 16; int zo = packet->zc * 16;
// 4J Stu - Unshare before we make any changes incase the server is // 4J Stu - Unshare before we make any changes incase the server is
@ -1011,7 +1011,7 @@ void ClientConnection::handleChunkTilesUpdate(
// If this is going to actually change a tile, we'll need to unshare // If this is going to actually change a tile, we'll need to unshare
int prevTile = lc->getTile(x, y, z); int prevTile = lc->getTile(x, y, z);
if ((tile != prevTile && !forcedUnshare)) { if ((tile != prevTile && !forcedUnshare)) {
dimensionLevel->unshareChunkAt(xo, zo); dimensionLevel->unshareChunkAt(xo, zo);
forcedUnshare = true; forcedUnshare = true;
} }
@ -1056,12 +1056,9 @@ void ClientConnection::handleChunkTilesUpdate(
dimensionLevel->removeUnusedTileEntitiesInRegion( dimensionLevel->removeUnusedTileEntitiesInRegion(
xo + x, y, zo + z, xo + x + 1, y + 1, zo + z + 1); 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 zo); // 4J - added - only shares if chunks
// are same on server & client // are same on server & client
} }
} }
@ -1071,32 +1068,28 @@ void ClientConnection::handleBlockRegionUpdate(
MultiPlayerLevel* dimensionLevel = MultiPlayerLevel* dimensionLevel =
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx]; (MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
if (dimensionLevel) { if (dimensionLevel) {
int y1 = packet->y + packet->ys; int y1 = packet->y + packet->ys;
if (packet->bIsFullChunk) { if (packet->bIsFullChunk) {
y1 = Level::maxBuildHeight; y1 = Level::maxBuildHeight;
if (packet->buffer.size() > 0) { if (packet->buffer.size() > 0) {
LevelChunk::reorderBlocksAndDataToXZY(packet->y, packet->xs, LevelChunk::reorderBlocksAndDataToXZY(packet->y, packet->xs,
packet->ys, packet->zs, packet->ys, packet->zs,
&packet->buffer); &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->x + packet->xs - 1, y1 - 1,
packet->z + packet->zs - 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 // this call
dimensionLevel->setBlocksAndData(packet->x, packet->y, packet->z, dimensionLevel->setBlocksAndData(packet->x, packet->y, packet->z,
packet->xs, packet->ys, packet->zs, packet->xs, packet->ys, packet->zs,
packet->buffer, packet->bIsFullChunk); packet->buffer, packet->bIsFullChunk);
// OutputDebugString("END BRU\n"); // 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 // 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 // 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 // bug where chests can't be properly placed again in a location after
@ -1105,17 +1098,14 @@ void ClientConnection::handleBlockRegionUpdate(
packet->x, packet->y, packet->z, packet->x + packet->xs, y1, packet->x, packet->y, packet->z, packet->x + packet->xs, y1,
packet->z + packet->zs); packet->z + packet->zs);
// If this is a full packet for a chunk, make sure that the cache now // 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 // 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 // whether to bother rendering mobs or not, so we don't have them in
// crazy positions before the data is there // crazy positions before the data is there
if (packet->bIsFullChunk) { if (packet->bIsFullChunk) {
dimensionLevel->dataReceivedForChunk(packet->x >> 4, dimensionLevel->dataReceivedForChunk(packet->x >> 4,
packet->z >> 4); packet->z >> 4);
} }
} }
} }
@ -1135,7 +1125,6 @@ void ClientConnection::handleTileUpdate(
MultiPlayerLevel* dimensionLevel = MultiPlayerLevel* dimensionLevel =
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx]; (MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
if (dimensionLevel) { if (dimensionLevel) {
if (g_NetworkManager.IsHost()) { if (g_NetworkManager.IsHost()) {
// 4J Stu - Unshare before we make any changes incase the server is // 4J Stu - Unshare before we make any changes incase the server is
// already another step ahead of us Fix for #7904 - Gameplay: // already another step ahead of us Fix for #7904 - Gameplay:
@ -1147,8 +1136,7 @@ void ClientConnection::handleTileUpdate(
int prevData = int prevData =
dimensionLevel->getData(packet->x, packet->y, packet->z); dimensionLevel->getData(packet->x, packet->y, packet->z);
if (packet->block != prevTile || packet->data != prevData) { 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); 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); packet->x, packet->y, packet->z, packet->block, packet->data);
// 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 // 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 // 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->x, packet->y, packet->z, packet->x + 1, packet->y + 1,
packet->z + 1); packet->z + 1);
dimensionLevel->shareChunkAt( dimensionLevel->shareChunkAt(
packet->x, packet->z); // 4J - added - only shares if chunks are packet->x, packet->z); // 4J - added - only shares if chunks are
// same on server & client // same on server & client
} }
} }
@ -2438,7 +2421,7 @@ void ClientConnection::handleRespawn(std::shared_ptr<RespawnPacket> packet) {
void ClientConnection::handleExplosion(std::shared_ptr<ExplodePacket> packet) { void ClientConnection::handleExplosion(std::shared_ptr<ExplodePacket> packet) {
if (!packet->m_bKnockbackOnly) { if (!packet->m_bKnockbackOnly) {
// app.DebugPrintf("Received ExplodePacket with explosion data\n"); // 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); packet->y, packet->z, packet->r);
// Fix for #81758 - TCR 006 BAS Non-Interactive Pause: TU9: Performance: // Fix for #81758 - TCR 006 BAS Non-Interactive Pause: TU9: Performance:
@ -2454,7 +2437,6 @@ void ClientConnection::handleExplosion(std::shared_ptr<ExplodePacket> packet) {
e->finalizeExplosion(true, &packet->toBlow); e->finalizeExplosion(true, &packet->toBlow);
mpLevel->enableResetChanges(true); mpLevel->enableResetChanges(true);
delete e; delete e;
} else { } else {
// app.DebugPrintf("Received ExplodePacket with knockback only data\n"); // app.DebugPrintf("Received ExplodePacket with knockback only data\n");
@ -2708,8 +2690,8 @@ void ClientConnection::handleContainerAck(
} }
if (menu != nullptr) { if (menu != nullptr) {
if (!packet->accepted) { if (!packet->accepted) {
send(std::make_shared<ContainerAckPacket>( send(std::make_shared<ContainerAckPacket>(packet->containerId,
packet->containerId, packet->uid, true)); packet->uid, true));
} }
} }
} }
@ -2833,9 +2815,8 @@ void ClientConnection::handleContainerClose(
void ClientConnection::handleTileEvent( void ClientConnection::handleTileEvent(
std::shared_ptr<TileEventPacket> packet) { std::shared_ptr<TileEventPacket> 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); packet->b0, packet->b1);
} }
void ClientConnection::handleTileDestruction( void ClientConnection::handleTileDestruction(
@ -2877,8 +2858,7 @@ void ClientConnection::handleGameEvent(
app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n", app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n",
m_userIndex); m_userIndex);
// This just allows it to be shown // This just allows it to be shown
if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != nullptr)
nullptr)
minecraft->localgameModes[InputManager.GetPrimaryPad()] minecraft->localgameModes[InputManager.GetPrimaryPad()]
->getTutorial() ->getTutorial()
->showTutorialPopup(false); ->showTutorialPopup(false);
@ -3446,7 +3426,8 @@ void ClientConnection::checkDeferredEntityLinkPackets(int newEntityId) {
bool remove = false; bool remove = false;
// Only consider recently deferred packets // 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) { if (tickInterval < MAX_ENTITY_LINK_DEFERRAL_INTERVAL) {
// Note: we assume it's the destination entity // Note: we assume it's the destination entity
if (deferred->m_packet->destId == newEntityId) { if (deferred->m_packet->destId == newEntityId) {

View file

@ -26,8 +26,7 @@ MultiPlayerChunkCache::MultiPlayerChunkCache(Level* level) {
memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE); memset(hasData, 0, sizeof(bool) * XZSIZE * XZSIZE);
std::vector<uint8_t> emptyBlocks(16 * 16 * Level::maxBuildHeight); std::vector<uint8_t> emptyBlocks(16 * 16 * Level::maxBuildHeight);
emptyChunk = new EmptyLevelChunk( emptyChunk = new EmptyLevelChunk(level, emptyBlocks, 0, 0);
level, emptyBlocks, 0, 0);
// For normal world dimension, create a chunk that can be used to create the // For normal world dimension, create a chunk that can be used to create the
// illusion of infinite water at the edge of the world // 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); waterChunk = new WaterLevelChunk(level, bytes, 0, 0);
if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) { if (level->getLevelData()->getGenerator() == LevelType::lvl_flat) {
for (int x = 0; x < 16; x++) for (int x = 0; x < 16; x++)
for (int y = 0; y < 128; y++) for (int y = 0; y < 128; y++)

View file

@ -129,21 +129,18 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
} }
if (localPlayerMode->isCreative()) { if (localPlayerMode->isCreative()) {
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>( PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
creativeDestroyBlock(minecraft, this, x, y, z, face); creativeDestroyBlock(minecraft, this, x, y, z, face);
destroyDelay = 5; destroyDelay = 5;
} else if (!isDestroying || !sameDestroyTarget(x, y, z)) { } else if (!isDestroying || !sameDestroyTarget(x, y, z)) {
if (isDestroying) { if (isDestroying) {
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>( PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, face));
yDestroyBlock, zDestroyBlock, face));
} }
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>( PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
int t = minecraft->level->getTile(x, y, z); int t = minecraft->level->getTile(x, y, z);
if (t > 0 && destroyProgress == 0) if (t > 0 && destroyProgress == 0)
Tile::tiles[t]->attack(minecraft->level, x, y, z, 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() { void MultiPlayerGameMode::stopDestroyBlock() {
if (isDestroying) { if (isDestroying) {
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>( PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock, yDestroyBlock, zDestroyBlock, -1));
yDestroyBlock, zDestroyBlock, -1));
} }
isDestroying = false; isDestroying = false;
@ -199,9 +195,8 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
if (localPlayerMode->isCreative()) { if (localPlayerMode->isCreative()) {
destroyDelay = 5; destroyDelay = 5;
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>( PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
creativeDestroyBlock(minecraft, this, x, y, z, face); creativeDestroyBlock(minecraft, this, x, y, z, face);
return; return;
} }
@ -232,9 +227,8 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
if (destroyProgress >= 1) { if (destroyProgress >= 1) {
isDestroying = false; isDestroying = false;
connection->send( connection->send(std::make_shared<PlayerActionPacket>(
std::make_shared<PlayerActionPacket>( PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face));
PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face));
destroyBlock(x, y, z, face); destroyBlock(x, y, z, face);
destroyProgress = 0; destroyProgress = 0;
destroyTicks = 0; destroyTicks = 0;
@ -533,6 +527,5 @@ bool MultiPlayerGameMode::handleCraftItem(int recipe,
void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal, void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal,
std::shared_ptr<Player> player) { std::shared_ptr<Player> player) {
player->SetDebugOptions(uiVal); player->SetDebugOptions(uiVal);
connection->send( connection->send(std::make_shared<DebugOptionsPacket>(uiVal));
std::make_shared<DebugOptionsPacket>(uiVal));
} }

View file

@ -55,8 +55,8 @@ MultiPlayerLevel::ResetInfo::ResetInfo(int x, int y, int z, int tile,
MultiPlayerLevel::MultiPlayerLevel(ClientConnection* connection, MultiPlayerLevel::MultiPlayerLevel(ClientConnection* connection,
LevelSettings* levelSettings, int dimension, LevelSettings* levelSettings, int dimension,
int difficulty) int difficulty)
: Level(std::make_shared<MockedLevelStorage>(), : Level(std::make_shared<MockedLevelStorage>(), L"MpServer",
L"MpServer", Dimension::getNew(dimension), levelSettings, false) { Dimension::getNew(dimension), levelSettings, false) {
minecraft = Minecraft::GetInstance(); minecraft = Minecraft::GetInstance();
// 4J - this this used to be called in parent ctor via a virtual fn // 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() { void MultiPlayerLevel::tick() {
setGameTime(getGameTime() + 1); setGameTime(getGameTime() + 1);
if (getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) { if (getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) {
// 4J: Debug setting added to keep it at day time // 4J: Debug setting added to keep it at day time
#if !defined(_FINAL_BUILD) #if !defined(_FINAL_BUILD)
@ -141,8 +141,7 @@ void MultiPlayerLevel::tick() {
} }
}*/ }*/
{
{
std::lock_guard<std::recursive_mutex> lock(m_entitiesCS); std::lock_guard<std::recursive_mutex> lock(m_entitiesCS);
for (int i = 0; i < 10 && !reEntries.empty(); i++) { for (int i = 0; i < 10 && !reEntries.empty(); i++) {
std::shared_ptr<Entity> e = *(reEntries.begin()); std::shared_ptr<Entity> e = *(reEntries.begin());
@ -152,8 +151,7 @@ void MultiPlayerLevel::tick() {
} }
} }
// 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 // Nether
std::vector<ClientConnection*> connectionsTemp = connections; std::vector<ClientConnection*> connectionsTemp = connections;
for (auto connection = connectionsTemp.begin(); for (auto connection = connectionsTemp.begin();
@ -161,8 +159,7 @@ void MultiPlayerLevel::tick() {
(*connection)->tick(); (*connection)->tick();
} }
unsigned int lastIndexToRemove = 0;
unsigned int lastIndexToRemove = 0;
bool eraseElements = false; bool eraseElements = false;
for (unsigned int i = 0; i < updatesToReset.size(); i++) { for (unsigned int i = 0; i < updatesToReset.size(); i++) {
ResetInfo& r = updatesToReset[i]; ResetInfo& r = updatesToReset[i];
@ -186,7 +183,6 @@ void MultiPlayerLevel::tick() {
updatesToReset.begin() + lastIndexToRemove); updatesToReset.begin() + lastIndexToRemove);
} }
chunkCache->tick(); chunkCache->tick();
tickTiles(); tickTiles();
@ -409,10 +405,9 @@ void MultiPlayerLevel::tickTiles() {
// resets in buildAndPrepareChunksToPoll rather than // resets in buildAndPrepareChunksToPoll rather than
// the calling functions // the calling functions
Level::tickTiles(); Level::tickTiles();
auto itEndCtp = chunksToPoll.end();
auto itEndCtp = chunksToPoll.end();
for (auto it = chunksToPoll.begin(); it != itEndCtp; it++) { for (auto it = chunksToPoll.begin(); it != itEndCtp; it++) {
ChunkPos cp = *it; ChunkPos cp = *it;
int xo = cp.x * 16; int xo = cp.x * 16;
@ -422,8 +417,6 @@ void MultiPlayerLevel::tickTiles() {
tickClientSideTiles(xo, zo, lc); tickClientSideTiles(xo, zo, lc);
} }
} }
void MultiPlayerLevel::setChunkVisible(int x, int z, bool visible) { void MultiPlayerLevel::setChunkVisible(int x, int z, bool visible) {
@ -912,10 +905,9 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection* c,
} }
void MultiPlayerLevel::tickAllConnections() { void MultiPlayerLevel::tickAllConnections() {
for (auto it = connections.begin(); it < connections.end(); ++it) { for (auto it = connections.begin(); it < connections.end(); ++it) {
(*it)->tick(); (*it)->tick();
} }
} }
void MultiPlayerLevel::dataReceivedForChunk(int x, int z) { void MultiPlayerLevel::dataReceivedForChunk(int x, int z) {

View file

@ -99,12 +99,10 @@ void MultiplayerLocalPlayer::tick() {
if (minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition( if (minecraft->localgameModes[m_iPad]->getTutorial()->canMoveToPosition(
tempX, tempY, tempZ, x, y, z)) { tempX, tempY, tempZ, x, y, z)) {
if (isRiding()) { if (isRiding()) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::Rot>(
std::make_shared<MovePlayerPacket::Rot>( yRot, xRot, onGround, abilities.flying));
yRot, xRot, onGround, abilities.flying)); connection->send(std::make_shared<PlayerInputPacket>(
connection->send( xxa, yya, input->jumping, input->sneaking));
std::make_shared<PlayerInputPacket>(
xxa, yya, input->jumping, input->sneaking));
} else { } else {
sendPosition(); sendPosition();
} }
@ -119,13 +117,11 @@ void MultiplayerLocalPlayer::sendPosition() {
bool sprinting = isSprinting(); bool sprinting = isSprinting();
if (sprinting != lastSprinting) { if (sprinting != lastSprinting) {
if (sprinting) if (sprinting)
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::START_SPRINTING));
shared_from_this(), PlayerCommandPacket::START_SPRINTING));
else else
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::STOP_SPRINTING));
shared_from_this(), PlayerCommandPacket::STOP_SPRINTING));
lastSprinting = sprinting; lastSprinting = sprinting;
} }
@ -133,13 +129,11 @@ void MultiplayerLocalPlayer::sendPosition() {
bool sneaking = isSneaking(); bool sneaking = isSneaking();
if (sneaking != lastSneaked) { if (sneaking != lastSneaked) {
if (sneaking) if (sneaking)
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::START_SNEAKING));
shared_from_this(), PlayerCommandPacket::START_SNEAKING));
else else
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::STOP_SNEAKING));
shared_from_this(), PlayerCommandPacket::STOP_SNEAKING));
lastSneaked = sneaking; lastSneaked = sneaking;
} }
@ -147,13 +141,11 @@ void MultiplayerLocalPlayer::sendPosition() {
bool idle = isIdle(); bool idle = isIdle();
if (idle != lastIdle) { if (idle != lastIdle) {
if (idle) if (idle)
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::START_IDLEANIM));
shared_from_this(), PlayerCommandPacket::START_IDLEANIM));
else else
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM));
shared_from_this(), PlayerCommandPacket::STOP_IDLEANIM));
lastIdle = idle; lastIdle = idle;
} }
@ -169,23 +161,19 @@ void MultiplayerLocalPlayer::sendPosition() {
positionReminder >= POSITION_REMINDER_INTERVAL; positionReminder >= POSITION_REMINDER_INTERVAL;
bool rot = rydd != 0 || rxdd != 0; bool rot = rydd != 0 || rxdd != 0;
if (riding != nullptr) { if (riding != nullptr) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::PosRot>(
std::make_shared<MovePlayerPacket::PosRot>( xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying));
xd, -999, -999, zd, yRot, xRot, onGround, abilities.flying));
move = false; move = false;
} else { } else {
if (move && rot) { if (move && rot) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::PosRot>(
std::make_shared<MovePlayerPacket::PosRot>( x, bb.y0, y, z, yRot, xRot, onGround, abilities.flying));
x, bb.y0, y, z, yRot, xRot, onGround, abilities.flying));
} else if (move) { } else if (move) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::Pos>(
std::make_shared<MovePlayerPacket::Pos>( x, bb.y0, y, z, onGround, abilities.flying));
x, bb.y0, y, z, onGround, abilities.flying));
} else if (rot) { } else if (rot) {
connection->send( connection->send(std::make_shared<MovePlayerPacket::Rot>(
std::make_shared<MovePlayerPacket::Rot>( yRot, xRot, onGround, abilities.flying));
yRot, xRot, onGround, abilities.flying));
} else { } else {
connection->send(std::shared_ptr<MovePlayerPacket>( connection->send(std::shared_ptr<MovePlayerPacket>(
new MovePlayerPacket(onGround, abilities.flying))); new MovePlayerPacket(onGround, abilities.flying)));
@ -295,8 +283,7 @@ void MultiplayerLocalPlayer::clientSideCloseContainer() {
LocalPlayer::closeContainer(); LocalPlayer::closeContainer();
} }
void MultiplayerLocalPlayer::hurtTo(float newHealth, void MultiplayerLocalPlayer::hurtTo(float newHealth, uint8_t damageSource) {
uint8_t damageSource) {
if (flashOnSetHealth) { if (flashOnSetHealth) {
LocalPlayer::hurtTo(newHealth, damageSource); LocalPlayer::hurtTo(newHealth, damageSource);
} else { } else {
@ -305,7 +292,8 @@ void MultiplayerLocalPlayer::hurtTo(float newHealth,
} }
} }
void MultiplayerLocalPlayer::awardStat(Stat* stat, const std::vector<uint8_t>& param) { void MultiplayerLocalPlayer::awardStat(Stat* stat,
const std::vector<uint8_t>& param) {
if (stat == nullptr) { if (stat == nullptr) {
return; return;
} }
@ -317,7 +305,8 @@ void MultiplayerLocalPlayer::awardStat(Stat* stat, const std::vector<uint8_t>& p
} }
} }
void MultiplayerLocalPlayer::awardStatFromServer(Stat* stat, std::vector<uint8_t>& param) { void MultiplayerLocalPlayer::awardStatFromServer(Stat* stat,
std::vector<uint8_t>& param) {
if (stat != nullptr && !stat->awardLocallyOnly) { if (stat != nullptr && !stat->awardLocallyOnly) {
LocalPlayer::awardStat(stat, param); LocalPlayer::awardStat(stat, param);
} }
@ -331,16 +320,14 @@ void MultiplayerLocalPlayer::onUpdateAbilities() {
bool MultiplayerLocalPlayer::isLocalPlayer() { return true; } bool MultiplayerLocalPlayer::isLocalPlayer() { return true; }
void MultiplayerLocalPlayer::sendRidingJump() { void MultiplayerLocalPlayer::sendRidingJump() {
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::RIDING_JUMP,
shared_from_this(), PlayerCommandPacket::RIDING_JUMP, (int)(getJumpRidingScale() * 100.0f)));
(int)(getJumpRidingScale() * 100.0f)));
} }
void MultiplayerLocalPlayer::sendOpenInventory() { void MultiplayerLocalPlayer::sendOpenInventory() {
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY));
shared_from_this(), PlayerCommandPacket::OPEN_INVENTORY));
} }
void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) { void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
@ -371,9 +358,8 @@ void MultiplayerLocalPlayer::ride(std::shared_ptr<Entity> e) {
} }
void MultiplayerLocalPlayer::StopSleeping() { void MultiplayerLocalPlayer::StopSleeping() {
connection->send( connection->send(std::make_shared<PlayerCommandPacket>(
std::make_shared<PlayerCommandPacket>( shared_from_this(), PlayerCommandPacket::STOP_SLEEPING));
shared_from_this(), PlayerCommandPacket::STOP_SLEEPING));
} }
// 4J Added // 4J Added
@ -398,10 +384,9 @@ void MultiplayerLocalPlayer::setAndBroadcastCustomCape(std::uint32_t capeId) {
customTextureUrl2.c_str()); customTextureUrl2.c_str());
#endif #endif
if (getCustomCape() != oldCapeIndex) if (getCustomCape() != oldCapeIndex)
connection->send( connection->send(std::make_shared<TextureChangePacket>(
std::make_shared<TextureChangePacket>( shared_from_this(), TextureChangePacket::e_TextureChange_Cape,
shared_from_this(), TextureChangePacket::e_TextureChange_Cape, app.GetPlayerCapeName(GetXboxPad())));
app.GetPlayerCapeName(GetXboxPad())));
} }
// 4J added for testing. This moves the player in a repeated sequence of 2 // 4J added for testing. This moves the player in a repeated sequence of 2

View file

@ -20,8 +20,7 @@ void ReceivingLevelScreen::init() { buttons.clear(); }
void ReceivingLevelScreen::tick() { void ReceivingLevelScreen::tick() {
tickCount++; tickCount++;
if (tickCount % 20 == 0) { if (tickCount % 20 == 0) {
connection->send( connection->send(std::make_shared<KeepAlivePacket>());
std::make_shared<KeepAlivePacket>());
} }
if (connection != nullptr) { if (connection != nullptr) {
connection->tick(); connection->tick();

View file

@ -104,7 +104,8 @@ void FireworksParticles::FireworksStarter::tick() {
int type = compoundTag->getByte(FireworksItem::TAG_E_TYPE); int type = compoundTag->getByte(FireworksItem::TAG_E_TYPE);
bool trail = compoundTag->getBoolean(FireworksItem::TAG_E_TRAIL); bool trail = compoundTag->getBoolean(FireworksItem::TAG_E_TRAIL);
bool flicker = compoundTag->getBoolean(FireworksItem::TAG_E_FLICKER); bool flicker = compoundTag->getBoolean(FireworksItem::TAG_E_FLICKER);
std::vector<int> colors = compoundTag->getIntArray(FireworksItem::TAG_E_COLORS); std::vector<int> colors =
compoundTag->getIntArray(FireworksItem::TAG_E_COLORS);
std::vector<int> fadeColors = std::vector<int> fadeColors =
compoundTag->getIntArray(FireworksItem::TAG_E_FADECOLORS); compoundTag->getIntArray(FireworksItem::TAG_E_FADECOLORS);
@ -120,7 +121,8 @@ void FireworksParticles::FireworksStarter::tick() {
150.0 / 245.0, -197.0 / 245.0, 150.0 / 245.0, -197.0 / 245.0,
0.0, -88.0 / 245.0, 0.0, -88.0 / 245.0,
}; };
std::vector<std::vector<double>> coordsArray(6, std::vector<double>(2)); std::vector<std::vector<double>> coordsArray(
6, std::vector<double>(2));
for (unsigned int i = 0; i < coordsArray.size(); ++i) { for (unsigned int i = 0; i < coordsArray.size(); ++i) {
for (unsigned int j = 0; j < coordsArray[i].size(); ++j) { for (unsigned int j = 0; j < coordsArray[i].size(); ++j) {
coordsArray[i][j] = coords[i][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.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, 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<std::vector<double>> coordsArray(12, std::vector<double>(2)); std::vector<std::vector<double>> coordsArray(
12, std::vector<double>(2));
for (unsigned int i = 0; i < coordsArray.size(); ++i) { for (unsigned int i = 0; i < coordsArray.size(); ++i) {
for (unsigned int j = 0; j < coordsArray[i].size(); ++j) { for (unsigned int j = 0; j < coordsArray[i].size(); ++j) {
coordsArray[i][j] = coords[i][j]; coordsArray[i][j] = coords[i][j];
@ -195,7 +198,8 @@ bool FireworksParticles::FireworksStarter::isFarAwayFromCamera() {
void FireworksParticles::FireworksStarter::createParticle( void FireworksParticles::FireworksStarter::createParticle(
double x, double y, double z, double xa, double ya, double za, double x, double y, double z, double xa, double ya, double za,
const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, bool trail, bool flicker) { const std::vector<int>& rgbColors, const std::vector<int>& fadeColors,
bool trail, bool flicker) {
std::shared_ptr<FireworksSparkParticle> fireworksSparkParticle = std::shared_ptr<FireworksSparkParticle> fireworksSparkParticle =
std::shared_ptr<FireworksSparkParticle>( std::shared_ptr<FireworksSparkParticle>(
new FireworksSparkParticle(level, x, y, z, xa, ya, za, engine)); new FireworksSparkParticle(level, x, y, z, xa, ya, za, engine));
@ -213,8 +217,8 @@ void FireworksParticles::FireworksStarter::createParticle(
} }
void FireworksParticles::FireworksStarter::createParticleBall( void FireworksParticles::FireworksStarter::createParticleBall(
double baseSpeed, int steps, const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, double baseSpeed, int steps, const std::vector<int>& rgbColors,
bool trail, bool flicker) { const std::vector<int>& fadeColors, bool trail, bool flicker) {
double xx = x; double xx = x;
double yy = y; double yy = y;
double zz = z; double zz = z;
@ -244,8 +248,9 @@ void FireworksParticles::FireworksStarter::createParticleBall(
} }
void FireworksParticles::FireworksStarter::createParticleShape( void FireworksParticles::FireworksStarter::createParticleShape(
double baseSpeed, std::vector<std::vector<double>> coords, const std::vector<int>& rgbColors, double baseSpeed, std::vector<std::vector<double>> coords,
const std::vector<int>& fadeColors, bool trail, bool flicker, bool flat) { const std::vector<int>& rgbColors, const std::vector<int>& fadeColors,
bool trail, bool flicker, bool flat) {
double sx = coords[0][0]; double sx = coords[0][0];
double sy = coords[0][1]; double sy = coords[0][1];
@ -285,7 +290,8 @@ void FireworksParticles::FireworksStarter::createParticleShape(
} }
void FireworksParticles::FireworksStarter::createParticleBurst( void FireworksParticles::FireworksStarter::createParticleBurst(
const std::vector<int>& rgbColors, const std::vector<int>& fadeColors, bool trail, bool flicker) { const std::vector<int>& rgbColors, const std::vector<int>& fadeColors,
bool trail, bool flicker) {
double baseOffX = random->nextGaussian() * .05; double baseOffX = random->nextGaussian() * .05;
double baseOffZ = random->nextGaussian() * .05; double baseOffZ = random->nextGaussian() * .05;

Some files were not shown because too many files have changed in this diff Show more