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() {}
// Primary pad (moved from Profile)
namespace { int s_inputPrimaryPad = 0; }
namespace {
int s_inputPrimaryPad = 0;
}
int C_4JInput::GetPrimaryPad() { return s_inputPrimaryPad; }
void C_4JInput::SetPrimaryPad(int iPad) { s_inputPrimaryPad = iPad; }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -145,8 +145,8 @@ std::vector<uint8_t> ArchiveFile::getFile(const std::wstring& filename) {
uncompressedBuffer, &decompressedSize, out.data() + 4,
out.size() - 4);
out = std::vector<uint8_t>(uncompressedBuffer, uncompressedBuffer + decompressedSize);
out = std::vector<uint8_t>(uncompressedBuffer,
uncompressedBuffer + decompressedSize);
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 =
Recipes::getInstance()->getRecipeIngredientsArray();
int iRecipeC = (int)recipes->size();
@ -871,7 +872,8 @@ void IUIScene_CraftingMenu::CheckRecipesAvailable() {
// run through the canbemade list and update the icons displayed
int iIndex = 0;
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
// std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray();
@ -993,7 +995,8 @@ void IUIScene_CraftingMenu::UpdateHighlight() {
//
//////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateVerticalSlots() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
// std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray();
@ -1064,7 +1067,8 @@ void IUIScene_CraftingMenu::UpdateVerticalSlots() {
//
//////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::DisplayIngredients() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
// std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray();
@ -1231,7 +1235,8 @@ void IUIScene_CraftingMenu::DisplayIngredients() {
//////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) {
int iIDSString = 0;
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
// std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray();
@ -1319,7 +1324,8 @@ void IUIScene_CraftingMenu::UpdateDescriptionText(bool bCanBeMade) {
//
//////////////////////////////////////////////////////////////////////////
void IUIScene_CraftingMenu::UpdateTooltips() {
// std::vector<Recipy*> *recipes = ((Recipes *)Recipes::getInstance())->getRecipies();
// std::vector<Recipy*> *recipes = ((Recipes
// *)Recipes::getInstance())->getRecipies();
Recipy::INGREDIENTS_REQUIRED* pRecipeIngredientsRequired =
Recipes::getInstance()->getRecipeIngredientsArray();
// Update tooltips

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -147,7 +147,8 @@ private:
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 {
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 ((*it)->isVisible()) {
(*it)->render(width, height, viewport);
}
}
}
@ -162,7 +161,6 @@ void UILayer::render(S32 width, S32 height, C4JRender::eViewportType viewport) {
m_sceneStack[lowestRenderable]->getSceneType() ==
eUIScene_Timer)) {
m_sceneStack[lowestRenderable]->render(width, height, viewport);
}
}
}

View file

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

View file

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

View file

@ -547,7 +547,7 @@ int32_t InitDevice() {
uint32_t numFeatureLevels = ARRAYSIZE(featureLevels);
DXGI_SWAP_CHAIN_DESC sd;
memset(&sd, 0, sizeof(sd));
memset(&sd, 0, sizeof(sd));
sd.BufferCount = 1;
sd.BufferDesc.Width = width;
sd.BufferDesc.Height = height;
@ -763,25 +763,22 @@ int main(int argc, const char* argv[]) {
ui.setScreenSize(fbw, fbh);
}
app.UpdateTime();
InputManager.Tick();
ProfileManager.Tick();
StorageManager.Tick();
RenderManager.Tick();
InputManager.Tick();
ProfileManager.Tick();
StorageManager.Tick();
RenderManager.Tick();
// Tick the social networking manager.
// CSocialManager::Instance()->Tick();
// CSocialManager::Instance()->Tick();
// Tick sentient.
// SentientManager.Tick();
// SentientManager.Tick();
g_NetworkManager.DoWork();
g_NetworkManager.DoWork();
// Render game graphics.
#if defined(ENABLE_JAVA_GUIS)
pMinecraft->run_middle();
@ -824,7 +821,7 @@ int main(int argc, const char* argv[]) {
RenderManager.Present();
ui.CheckMenuDisplayed();
// has the game defined profile data been changed (by a profile load)
// has the game defined profile data been changed (by a profile load)
if (app.uiGameDefinedDataChangedBitmask != 0) {
void* pData;
for (int i = 0; i < XUSER_MAX_COUNT; i++) {
@ -855,10 +852,8 @@ int main(int argc, const char* argv[]) {
// clear the flag
app.uiGameDefinedDataChangedBitmask = 0;
}
g_NetworkManager.DoWork();
g_NetworkManager.DoWork();
// Any threading type things to deal with from the xui side?
app.HandleXuiActions();

View file

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

View file

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

View file

@ -97,11 +97,9 @@ void ConsoleUIController::render() {
void ConsoleUIController::beginIggyCustomDraw4J(
IggyCustomDrawCallbackRegion* region, CustomDrawData* customDrawRegion) {
// get the correct object-to-world matrix from GDraw, and set the render
// get the correct object-to-world matrix from GDraw, and set the render
// state to a normal state
gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat);
}
CustomDrawData* ConsoleUIController::setupCustomDraw(
@ -112,7 +110,7 @@ CustomDrawData* ConsoleUIController::setupCustomDraw(
customDrawRegion->y0 = region->y0;
customDrawRegion->y1 = region->y1;
// get the correct object-to-world matrix from GDraw, and set the render
// get the correct object-to-world matrix from GDraw, and set the render
// state to a normal state
gdraw_D3D11_BeginCustomDraw_4J(region, customDrawRegion->mat);
@ -138,7 +136,6 @@ void ConsoleUIController::endCustomDraw(IggyCustomDrawCallbackRegion* region) {
endCustomDrawGameStateAndMatrices();
gdraw_D3D11_EndCustomDraw(region);
}
void ConsoleUIController::setTileOrigin(S32 xPos, S32 yPos) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -8,7 +8,8 @@ class DataInput {
public:
virtual int read() = 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 uint8_t readByte() = 0;
virtual unsigned char readUnsignedByte() = 0;

View file

@ -16,7 +16,8 @@ public:
DataInputStream(InputStream* in);
virtual int read();
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 bool readBoolean();
virtual uint8_t readByte();

View file

@ -23,7 +23,8 @@ public:
virtual void write(unsigned int 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 writeByte(uint8_t a);
virtual void writeDouble(double a);

View file

@ -14,7 +14,8 @@ public:
virtual ~FileInputStream();
virtual int read();
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 int64_t skip(int64_t n);

View file

@ -13,7 +13,8 @@ public:
virtual ~FileOutputStream();
virtual void write(unsigned int 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 flush();

View file

@ -14,7 +14,8 @@ public:
GZIPInputStream(InputStream* out) : stream(out) {};
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, 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);
};
virtual void close() { return stream->close(); };

View file

@ -12,7 +12,8 @@ public:
GZIPOutputStream(OutputStream* out) : stream(out) {};
virtual void write(unsigned int b) { stream->write(b); };
virtual void write(const std::vector<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);
};
virtual void close() { stream->close(); };

View file

@ -12,7 +12,8 @@ public:
virtual int read() = 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 int64_t skip(int64_t n) = 0;

View file

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

View file

@ -393,7 +393,9 @@ ByteBuffer* ByteBuffer::put(std::vector<uint8_t>& inputArray) {
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.
// 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/File.h"
#include "console_helpers/PathHelper.h" // 4jcraft TODO
#include "console_helpers/StringHelpers.h" // 4jcraft TODO
#include "console_helpers/PathHelper.h" // 4jcraft TODO
#include "console_helpers/StringHelpers.h" // 4jcraft TODO
const wchar_t File::pathSeparator = L'/';

View file

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

View file

@ -12,9 +12,12 @@
#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)
: pos(offset), count(std::min(offset + length, (unsigned int)buf.size())), mark(offset) {
: pos(offset),
count(std::min(offset + length, (unsigned int)buf.size())),
mark(offset) {
this->buf = buf;
}
@ -59,7 +62,9 @@ int ByteArrayInputStream::read() {
// Returns:
// the total number of bytes read into the buffer, or -1 is there is no more
// data because the end of the stream has been reached.
int ByteArrayInputStream::read(std::vector<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.
// If pos equals count, then -1 is returned to indicate end of file. Otherwise,
@ -110,5 +115,4 @@ int64_t ByteArrayInputStream::skip(int64_t n) {
return k;
}
ByteArrayInputStream::~ByteArrayInputStream() {
}
ByteArrayInputStream::~ByteArrayInputStream() {}

View file

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

View file

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

View file

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

View file

@ -5,7 +5,7 @@
#include "java/File.h"
#include "java/InputOutputStream/FileOutputStream.h"
#include "console_helpers/StringHelpers.h" // 4jcraft TODO
#include "console_helpers/StringHelpers.h" // 4jcraft TODO
// Creates a file output stream to write to the file represented by the
// specified File object. A new FileDescriptor object is created to represent

View file

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

View file

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

View file

@ -2,7 +2,6 @@
#include <memory>
#include "minecraft/client/gui/inventory/AbstractContainerScreen.h"
#include "minecraft/world/inventory/AnvilMenu.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
itemRenderer->renderGuiItem(
font, minecraft->textures,
std::make_shared<ItemInstance>(Item::emerald_Id, 1, 0),
xo + 42, yo + 109);
std::make_shared<ItemInstance>(Item::emerald_Id, 1, 0), xo + 42,
yo + 109);
itemRenderer->renderGuiItem(
font, minecraft->textures,
std::make_shared<ItemInstance>(Item::diamond_Id, 1, 0),
xo + 42 + 22, yo + 109);
std::make_shared<ItemInstance>(Item::diamond_Id, 1, 0), xo + 42 + 22,
yo + 109);
itemRenderer->renderGuiItem(font, minecraft->textures,
std::shared_ptr<ItemInstance>(
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;
rightWing->xRot = -std::numbers::pi * .05f;
rightWing->yRot = -std::numbers::pi * .40f;
rightWingTip->yRot = -std::numbers::pi * .55f;
rightWing->xRot = -std::numbers::pi * .05f;
rightWing->yRot = -std::numbers::pi * .40f;
rightWingTip->yRot = -std::numbers::pi * .55f;
leftWing->xRot = rightWing->xRot;
leftWing->yRot = -rightWing->yRot;
leftWingTip->yRot = -rightWingTip->yRot;

View file

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

View file

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

View file

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

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

View file

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

View file

@ -120,22 +120,38 @@ void SpiderModel::setupAnim(float time, float r, float bob, float yRot,
leg7->yRot = +ur * 2.0f - ro;
float c0 =
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 0 / 4.0f) * 0.4f) * r;
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 0 / 4.0f) *
0.4f) *
r;
float c1 =
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 2 / 4.0f) * 0.4f) * r;
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 2 / 4.0f) *
0.4f) *
r;
float c2 =
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 1 / 4.0f) * 0.4f) * r;
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 1 / 4.0f) *
0.4f) *
r;
float c3 =
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 3 / 4.0f) * 0.4f) * r;
-((float)cosf(time * 0.6662f * 2 + std::numbers::pi * 2 * 3 / 4.0f) *
0.4f) *
r;
float s0 =
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 0 / 4.0f) * 0.4f) * r;
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 0 / 4.0f) *
0.4f) *
r;
float s1 =
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 2 / 4.0f) * 0.4f) * r;
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 2 / 4.0f) *
0.4f) *
r;
float s2 =
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 1 / 4.0f) * 0.4f) * r;
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 1 / 4.0f) *
0.4f) *
r;
float s3 =
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 3 / 4.0f) * 0.4f) * r;
std::abs((float)sinf(time * 0.6662f + std::numbers::pi * 2 * 3 / 4.0f) *
0.4f) *
r;
leg0->yRot += +c0;
leg1->yRot += -c0;

View file

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

View file

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

View file

@ -62,9 +62,11 @@ void WitchModel::setupAnim(float time, float r, float bob, float yRot,
nose->translateX = nose->translateY = nose->translateZ = 0;
float speed = 0.01f * (entity->entityId % 10);
nose->xRot = (sin(entity->tickCount * speed) * 4.5f) * std::numbers::pi / 180;
nose->xRot =
(sin(entity->tickCount * speed) * 4.5f) * std::numbers::pi / 180;
nose->yRot = 0;
nose->zRot = (cos(entity->tickCount * speed) * 2.5f) * std::numbers::pi / 180;
nose->zRot =
(cos(entity->tickCount * speed) * 2.5f) * std::numbers::pi / 180;
if (holdingItem) {
nose->xRot = -0.9f;

View file

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

View file

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

View file

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

View file

@ -990,7 +990,7 @@ void ClientConnection::handleChunkTilesUpdate(
MultiPlayerLevel* dimensionLevel =
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
if (dimensionLevel) {
LevelChunk* lc = dimensionLevel->getChunk(packet->xc, packet->zc);
LevelChunk* lc = dimensionLevel->getChunk(packet->xc, packet->zc);
int xo = packet->xc * 16;
int zo = packet->zc * 16;
// 4J Stu - Unshare before we make any changes incase the server is
@ -1011,8 +1011,8 @@ void ClientConnection::handleChunkTilesUpdate(
// If this is going to actually change a tile, we'll need to unshare
int prevTile = lc->getTile(x, y, z);
if ((tile != prevTile && !forcedUnshare)) {
dimensionLevel->unshareChunkAt(xo, zo);
dimensionLevel->unshareChunkAt(xo, zo);
forcedUnshare = true;
}
@ -1056,12 +1056,9 @@ void ClientConnection::handleChunkTilesUpdate(
dimensionLevel->removeUnusedTileEntitiesInRegion(
xo + x, y, zo + z, xo + x + 1, y + 1, zo + z + 1);
}
dimensionLevel->shareChunkAt(xo,
dimensionLevel->shareChunkAt(xo,
zo); // 4J - added - only shares if chunks
// are same on server & client
}
}
@ -1071,32 +1068,28 @@ void ClientConnection::handleBlockRegionUpdate(
MultiPlayerLevel* dimensionLevel =
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
if (dimensionLevel) {
int y1 = packet->y + packet->ys;
if (packet->bIsFullChunk) {
y1 = Level::maxBuildHeight;
if (packet->buffer.size() > 0) {
LevelChunk::reorderBlocksAndDataToXZY(packet->y, packet->xs,
LevelChunk::reorderBlocksAndDataToXZY(packet->y, packet->xs,
packet->ys, packet->zs,
&packet->buffer);
}
}
dimensionLevel->clearResetRegion(packet->x, packet->y, packet->z,
dimensionLevel->clearResetRegion(packet->x, packet->y, packet->z,
packet->x + packet->xs - 1, y1 - 1,
packet->z + packet->zs - 1);
// Only full chunks send lighting information now - added flag to end of
// Only full chunks send lighting information now - added flag to end of
// this call
dimensionLevel->setBlocksAndData(packet->x, packet->y, packet->z,
packet->xs, packet->ys, packet->zs,
packet->buffer, packet->bIsFullChunk);
// OutputDebugString("END BRU\n");
// 4J - remove any tite entities in this region which are associated
// 4J - remove any tite entities in this region which are associated
// with a tile that is now no longer a tile entity. Without doing this
// we end up with stray tile entities kicking round, which leads to a
// bug where chests can't be properly placed again in a location after
@ -1104,18 +1097,15 @@ void ClientConnection::handleBlockRegionUpdate(
dimensionLevel->removeUnusedTileEntitiesInRegion(
packet->x, packet->y, packet->z, packet->x + packet->xs, y1,
packet->z + packet->zs);
// If this is a full packet for a chunk, make sure that the cache now
// considers that it has data for this chunk - this is used to determine
// whether to bother rendering mobs or not, so we don't have them in
// crazy positions before the data is there
if (packet->bIsFullChunk) {
dimensionLevel->dataReceivedForChunk(packet->x >> 4,
dimensionLevel->dataReceivedForChunk(packet->x >> 4,
packet->z >> 4);
}
}
}
@ -1135,7 +1125,6 @@ void ClientConnection::handleTileUpdate(
MultiPlayerLevel* dimensionLevel =
(MultiPlayerLevel*)minecraft->levels[packet->levelIdx];
if (dimensionLevel) {
if (g_NetworkManager.IsHost()) {
// 4J Stu - Unshare before we make any changes incase the server is
// already another step ahead of us Fix for #7904 - Gameplay:
@ -1147,8 +1136,7 @@ void ClientConnection::handleTileUpdate(
int prevData =
dimensionLevel->getData(packet->x, packet->y, packet->z);
if (packet->block != prevTile || packet->data != prevData) {
dimensionLevel->unshareChunkAt(packet->x, packet->z);
dimensionLevel->unshareChunkAt(packet->x, packet->z);
}
}
@ -1161,11 +1149,9 @@ void ClientConnection::handleTileUpdate(
dimensionLevel, packet->x, packet->y, packet->z);
}
bool tileWasSet = dimensionLevel->doSetTileAndData(
bool tileWasSet = dimensionLevel->doSetTileAndData(
packet->x, packet->y, packet->z, packet->block, packet->data);
// 4J - remove any tite entities in this region which are associated
// with a tile that is now no longer a tile entity. Without doing this
// we end up with stray tile entities kicking round, which leads to a
@ -1175,12 +1161,9 @@ void ClientConnection::handleTileUpdate(
packet->x, packet->y, packet->z, packet->x + 1, packet->y + 1,
packet->z + 1);
dimensionLevel->shareChunkAt(
dimensionLevel->shareChunkAt(
packet->x, packet->z); // 4J - added - only shares if chunks are
// same on server & client
}
}
@ -2438,9 +2421,9 @@ void ClientConnection::handleRespawn(std::shared_ptr<RespawnPacket> packet) {
void ClientConnection::handleExplosion(std::shared_ptr<ExplodePacket> packet) {
if (!packet->m_bKnockbackOnly) {
// app.DebugPrintf("Received ExplodePacket with explosion data\n");
Explosion* e = new Explosion(minecraft->level, nullptr, packet->x,
Explosion* e = new Explosion(minecraft->level, nullptr, packet->x,
packet->y, packet->z, packet->r);
// Fix for #81758 - TCR 006 BAS Non-Interactive Pause: TU9: Performance:
// Gameplay: After detonating bunch of TNT, game enters unresponsive
// state for couple of seconds. The changes we are making here have been
@ -2453,8 +2436,7 @@ void ClientConnection::handleExplosion(std::shared_ptr<ExplodePacket> packet) {
// rather than copying around
e->finalizeExplosion(true, &packet->toBlow);
mpLevel->enableResetChanges(true);
delete e;
} else {
// app.DebugPrintf("Received ExplodePacket with knockback only data\n");
@ -2708,8 +2690,8 @@ void ClientConnection::handleContainerAck(
}
if (menu != nullptr) {
if (!packet->accepted) {
send(std::make_shared<ContainerAckPacket>(
packet->containerId, packet->uid, true));
send(std::make_shared<ContainerAckPacket>(packet->containerId,
packet->uid, true));
}
}
}
@ -2833,9 +2815,8 @@ void ClientConnection::handleContainerClose(
void ClientConnection::handleTileEvent(
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);
}
void ClientConnection::handleTileDestruction(
@ -2877,8 +2858,7 @@ void ClientConnection::handleGameEvent(
app.DebugPrintf("handleGameEvent packet for WIN_GAME - %d\n",
m_userIndex);
// This just allows it to be shown
if (minecraft->localgameModes[InputManager.GetPrimaryPad()] !=
nullptr)
if (minecraft->localgameModes[InputManager.GetPrimaryPad()] != nullptr)
minecraft->localgameModes[InputManager.GetPrimaryPad()]
->getTutorial()
->showTutorialPopup(false);
@ -3446,7 +3426,8 @@ void ClientConnection::checkDeferredEntityLinkPackets(int newEntityId) {
bool remove = false;
// Only consider recently deferred packets
int tickInterval = PlatformTime::GetTickCount() - deferred->m_recievedTick;
int tickInterval =
PlatformTime::GetTickCount() - deferred->m_recievedTick;
if (tickInterval < MAX_ENTITY_LINK_DEFERRAL_INTERVAL) {
// Note: we assume it's the destination entity
if (deferred->m_packet->destId == newEntityId) {

View file

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

View file

@ -129,21 +129,18 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
}
if (localPlayerMode->isCreative()) {
connection->send(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
connection->send(std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
creativeDestroyBlock(minecraft, this, x, y, z, face);
destroyDelay = 5;
} else if (!isDestroying || !sameDestroyTarget(x, y, z)) {
if (isDestroying) {
connection->send(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
yDestroyBlock, zDestroyBlock, face));
connection->send(std::make_shared<PlayerActionPacket>(
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
yDestroyBlock, zDestroyBlock, face));
}
connection->send(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
connection->send(std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
int t = minecraft->level->getTile(x, y, z);
if (t > 0 && destroyProgress == 0)
Tile::tiles[t]->attack(minecraft->level, x, y, z,
@ -172,10 +169,9 @@ void MultiPlayerGameMode::startDestroyBlock(int x, int y, int z, int face) {
void MultiPlayerGameMode::stopDestroyBlock() {
if (isDestroying) {
connection->send(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
yDestroyBlock, zDestroyBlock, -1));
connection->send(std::make_shared<PlayerActionPacket>(
PlayerActionPacket::ABORT_DESTROY_BLOCK, xDestroyBlock,
yDestroyBlock, zDestroyBlock, -1));
}
isDestroying = false;
@ -199,9 +195,8 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
if (localPlayerMode->isCreative()) {
destroyDelay = 5;
connection->send(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
connection->send(std::make_shared<PlayerActionPacket>(
PlayerActionPacket::START_DESTROY_BLOCK, x, y, z, face));
creativeDestroyBlock(minecraft, this, x, y, z, face);
return;
}
@ -232,9 +227,8 @@ void MultiPlayerGameMode::continueDestroyBlock(int x, int y, int z, int face) {
if (destroyProgress >= 1) {
isDestroying = false;
connection->send(
std::make_shared<PlayerActionPacket>(
PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face));
connection->send(std::make_shared<PlayerActionPacket>(
PlayerActionPacket::STOP_DESTROY_BLOCK, x, y, z, face));
destroyBlock(x, y, z, face);
destroyProgress = 0;
destroyTicks = 0;
@ -533,6 +527,5 @@ bool MultiPlayerGameMode::handleCraftItem(int recipe,
void MultiPlayerGameMode::handleDebugOptions(unsigned int uiVal,
std::shared_ptr<Player> player) {
player->SetDebugOptions(uiVal);
connection->send(
std::make_shared<DebugOptionsPacket>(uiVal));
connection->send(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,
LevelSettings* levelSettings, int dimension,
int difficulty)
: Level(std::make_shared<MockedLevelStorage>(),
L"MpServer", Dimension::getNew(dimension), levelSettings, false) {
: Level(std::make_shared<MockedLevelStorage>(), L"MpServer",
Dimension::getNew(dimension), levelSettings, false) {
minecraft = Minecraft::GetInstance();
// 4J - this this used to be called in parent ctor via a virtual fn
@ -116,7 +116,7 @@ void MultiPlayerLevel::shareChunkAt(int x, int z) {
}
void MultiPlayerLevel::tick() {
setGameTime(getGameTime() + 1);
setGameTime(getGameTime() + 1);
if (getGameRules()->getBoolean(GameRules::RULE_DAYLIGHT)) {
// 4J: Debug setting added to keep it at day time
#if !defined(_FINAL_BUILD)
@ -140,9 +140,8 @@ void MultiPlayerLevel::tick() {
listeners[i]->skyColorChanged();
}
}*/
{
{
std::lock_guard<std::recursive_mutex> lock(m_entitiesCS);
for (int i = 0; i < 10 && !reEntries.empty(); i++) {
std::shared_ptr<Entity> e = *(reEntries.begin());
@ -151,18 +150,16 @@ void MultiPlayerLevel::tick() {
addEntity(e);
}
}
// 4J HEG - Copy the connections vector to prevent crash when moving to
// 4J HEG - Copy the connections vector to prevent crash when moving to
// Nether
std::vector<ClientConnection*> connectionsTemp = connections;
for (auto connection = connectionsTemp.begin();
connection < connectionsTemp.end(); ++connection) {
(*connection)->tick();
}
unsigned int lastIndexToRemove = 0;
unsigned int lastIndexToRemove = 0;
bool eraseElements = false;
for (unsigned int i = 0; i < updatesToReset.size(); i++) {
ResetInfo& r = updatesToReset[i];
@ -185,7 +182,6 @@ void MultiPlayerLevel::tick() {
updatesToReset.erase(updatesToReset.begin(),
updatesToReset.begin() + lastIndexToRemove);
}
chunkCache->tick();
tickTiles();
@ -409,10 +405,9 @@ void MultiPlayerLevel::tickTiles() {
// resets in buildAndPrepareChunksToPoll rather than
// the calling functions
Level::tickTiles();
Level::tickTiles();
auto itEndCtp = chunksToPoll.end();
auto itEndCtp = chunksToPoll.end();
for (auto it = chunksToPoll.begin(); it != itEndCtp; it++) {
ChunkPos cp = *it;
int xo = cp.x * 16;
@ -422,8 +417,6 @@ void MultiPlayerLevel::tickTiles() {
tickClientSideTiles(xo, zo, lc);
}
}
void MultiPlayerLevel::setChunkVisible(int x, int z, bool visible) {
@ -912,10 +905,9 @@ void MultiPlayerLevel::removeClientConnection(ClientConnection* c,
}
void MultiPlayerLevel::tickAllConnections() {
for (auto it = connections.begin(); it < connections.end(); ++it) {
for (auto it = connections.begin(); it < connections.end(); ++it) {
(*it)->tick();
}
}
void MultiPlayerLevel::dataReceivedForChunk(int x, int z) {

View file

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

View file

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

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