From d63f79325f85e014361eb8cf1e41eaebedb1ae71 Mon Sep 17 00:00:00 2001 From: void_17 Date: Mon, 2 Mar 2026 15:53:32 +0700 Subject: Get rid of MSVC's __int64 Use either int64_t, uint64_t or long long and unsigned long long, defined as per C++11 standard --- .../GameRules/ApplySchematicRuleDefinition.h | 8 ++--- .../Common/GameRules/ConsoleSchematicFile.cpp | 34 +++++++++---------- .../Common/GameRules/ConsoleSchematicFile.h | 6 ++-- Minecraft.Client/Common/GameRules/GameRule.h | 4 +-- .../Common/GameRules/GameRuleManager.cpp | 38 +++++++++++----------- .../Common/GameRules/LevelGenerationOptions.cpp | 30 ++++++++--------- .../Common/GameRules/LevelGenerationOptions.h | 12 +++---- 7 files changed, 66 insertions(+), 66 deletions(-) (limited to 'Minecraft.Client/Common/GameRules') diff --git a/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.h b/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.h index 21c42dea..e5dffb3c 100644 --- a/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.h +++ b/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.h @@ -19,17 +19,17 @@ private: ConsoleSchematicFile::ESchematicRotation m_rotation; int m_dimension; - __int64 m_totalBlocksChanged; - __int64 m_totalBlocksChangedLighting; + int64_t m_totalBlocksChanged; + int64_t m_totalBlocksChangedLighting; bool m_completed; void updateLocationBox(); -public: +public: ApplySchematicRuleDefinition(LevelGenerationOptions *levelGenOptions); ~ApplySchematicRuleDefinition(); virtual ConsoleGameRules::EGameRuleType getActionType() { return ConsoleGameRules::eGameRuleType_ApplySchematic; } - + virtual void writeAttributes(DataOutputStream *dos, UINT numAttrs); virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue); diff --git a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp index 4a4e27b2..0eef096b 100644 --- a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp +++ b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp @@ -38,7 +38,7 @@ void ConsoleSchematicFile::save(DataOutputStream *dos) dos->writeInt(m_zSize); byteArray ba(new BYTE[ m_data.length ], m_data.length); - Compression::getCompression()->CompressLZXRLE( ba.data, &ba.length, + Compression::getCompression()->CompressLZXRLE( ba.data, &ba.length, m_data.data, m_data.length); dos->writeInt(ba.length); @@ -71,13 +71,13 @@ void ConsoleSchematicFile::load(DataInputStream *dis) m_ySize = dis->readInt(); m_zSize = dis->readInt(); - int compressedSize = dis->readInt(); + int compressedSize = dis->readInt(); byteArray compressedBuffer(compressedSize); dis->readFully(compressedBuffer); if(m_data.data != NULL) { - delete [] m_data.data; + delete [] m_data.data; m_data.data = NULL; } @@ -145,7 +145,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis) double z = pos->get(2)->data; if( type == eTYPE_PAINTING || type == eTYPE_ITEM_FRAME ) - { + { x = ((IntTag *) eTag->get(L"TileX") )->data; y = ((IntTag *) eTag->get(L"TileY") )->data; z = ((IntTag *) eTag->get(L"TileZ") )->data; @@ -184,7 +184,7 @@ void ConsoleSchematicFile::save_tags(DataOutputStream *dos) delete tag; } -__int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) +int64_t ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) { int xStart = max(destinationBox->x0, (double)chunk->x*16); int xEnd = min(destinationBox->x1, (double)((xStart>>4)<<4) + 16); @@ -281,7 +281,7 @@ __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkB // blockData[i] = Tile::whiteStone_Id; // } //} - + PIXBeginNamedEvent(0,"Setting Block data"); chunk->setBlockData(blockData); PIXEndNamedEvent(); @@ -323,7 +323,7 @@ __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkB // At the point that this is called, we have all the neighbouring chunks loaded in (and generally post-processed, apart from this lighting pass), so // we can do the sort of lighting that might propagate out of the chunk. -__int64 ConsoleSchematicFile::applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) +int64_t ConsoleSchematicFile::applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot) { int xStart = max(destinationBox->x0, (double)chunk->x*16); int xEnd = min(destinationBox->x1, (double)((xStart>>4)<<4) + 16); @@ -447,7 +447,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, shared_ptr teCopy = chunk->getTileEntity( (int)targetX & 15, (int)targetY & 15, (int)targetZ & 15 ); if ( teCopy != NULL ) - { + { CompoundTag *teData = new CompoundTag(); te->save(teData); @@ -480,7 +480,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, for(AUTO_VAR(it, m_entities.begin()); it != m_entities.end();) { Vec3 *source = it->first; - + double targetX = source->x; double targetY = source->y + destinationBox->y0; double targetZ = source->z; @@ -500,7 +500,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, if( e->GetType() == eTYPE_PAINTING ) { shared_ptr painting = dynamic_pointer_cast(e); - + double tileX = painting->xTile; double tileZ = painting->zTile; schematicCoordToChunkCoord(destinationBox, painting->xTile, painting->zTile, rot, tileX, tileZ); @@ -513,7 +513,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox, else if( e->GetType() == eTYPE_ITEM_FRAME ) { shared_ptr frame = dynamic_pointer_cast(e); - + double tileX = frame->xTile; double tileZ = frame->zTile; schematicCoordToChunkCoord(destinationBox, frame->xTile, frame->zTile, rot, tileX, tileZ); @@ -561,7 +561,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l zStart-=1; else if(zStart < 0 && zStart%2 !=0) zStart-=1; - + // We want the end to be odd to have a total size that is even if(xEnd > 0 && xEnd%2 == 0) xEnd+=1; @@ -615,7 +615,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l // Every x is a whole row for(int xPos = xStart; xPos < xStart + xSize; ++xPos) - { + { int xc = xPos >> 4; int x0 = xPos - xc * 16; @@ -624,7 +624,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l if (x1 > 16) x1 = 16; for(int zPos = zStart; zPos < zStart + zSize;) - { + { int zc = zPos >> 4; int z0 = zStart - zc * 16; @@ -718,7 +718,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l { CompoundTag *eTag = new CompoundTag(); if( e->save(eTag) ) - { + { ListTag *pos = (ListTag *) eTag->getList(L"Pos"); pos->get(0)->data -= xStart; @@ -726,7 +726,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l pos->get(2)->data -= zStart; if( e->GetType() == eTYPE_PAINTING || e->GetType() == eTYPE_ITEM_FRAME ) - { + { ((IntTag *) eTag->get(L"TileX") )->data -= xStart; ((IntTag *) eTag->get(L"TileY") )->data -= yStart; ((IntTag *) eTag->get(L"TileZ") )->data -= zStart; @@ -767,7 +767,7 @@ void ConsoleSchematicFile::getBlocksAndData(LevelChunk *chunk, byteArray *data, // skyLightP += skyLightData.length; // return; //} - + bool bHasLower, bHasUpper; bHasLower = bHasUpper = false; int lowerY0, lowerY1, upperY0, upperY1; diff --git a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.h b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.h index f37a6058..b0eebf9e 100644 --- a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.h +++ b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.h @@ -58,7 +58,7 @@ private: vector > m_tileEntities; vector< pair > m_entities; -public: +public: byteArray m_data; public: @@ -72,8 +72,8 @@ public: void save(DataOutputStream *dos); void load(DataInputStream *dis); - __int64 applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot); - __int64 applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot); + int64_t applyBlocksAndData(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot); + int64_t applyLighting(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot); void applyTileEntities(LevelChunk *chunk, AABB *chunkBox, AABB *destinationBox, ESchematicRotation rot); static void generateSchematicFile(DataOutputStream *dos, Level *level, int xStart, int yStart, int zStart, int xEnd, int yEnd, int zEnd, bool bSaveMobs, Compression::ECompressionTypes); diff --git a/Minecraft.Client/Common/GameRules/GameRule.h b/Minecraft.Client/Common/GameRules/GameRule.h index bdc2ceff..3b9dba7e 100644 --- a/Minecraft.Client/Common/GameRules/GameRule.h +++ b/Minecraft.Client/Common/GameRules/GameRule.h @@ -14,7 +14,7 @@ public: typedef struct _ValueType { union{ - __int64 i64; + int64_t i64; int i; char c; bool b; @@ -44,7 +44,7 @@ public: virtual ~GameRule(); Connection *getConnection() { return m_connection; } - + ValueType getParameter(const wstring ¶meterName); void setParameter(const wstring ¶meterName,ValueType value); GameRuleDefinition *getGameRuleDefinition(); diff --git a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp index 0c6a7804..373030d4 100644 --- a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp +++ b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp @@ -77,7 +77,7 @@ WCHAR *GameRuleManager::wchAttrNameA[] = L"spawnY", // eGameRuleAttr_spawnY L"spawnZ", // eGameRuleAttr_spawnZ L"orientation", - L"dimension", + L"dimension", L"topTileId", // eGameRuleAttr_topTileId L"biomeId", // eGameRuleAttr_biomeId L"feature", // eGameRuleAttr_feature @@ -114,7 +114,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack) readRuleFile(createdLevelGenerationOptions, dData, dSize, strings); createdLevelGenerationOptions->setSrc( LevelGenerationOptions::eSrc_fromDLC ); - + //createdLevelGenerationOptions->setSrc( LevelGenerationOptions::eSrc_fromDLC ); dlcHeader->lgo = createdLevelGenerationOptions; @@ -130,12 +130,12 @@ void GameRuleManager::loadGameRules(DLCPack *pack) LevelGenerationOptions *createdLevelGenerationOptions = new LevelGenerationOptions(); // = loadGameRules(dData, dSize); //, strings); - + createdLevelGenerationOptions->setGrSource( new JustGrSource() ); readRuleFile(createdLevelGenerationOptions, dData, dSize, strings); createdLevelGenerationOptions->setSrc( LevelGenerationOptions::eSrc_tutorial ); - + //createdLevelGenerationOptions->set_DLCGameRulesFile( dlcFile ); createdLevelGenerationOptions->setLoadedData(); @@ -169,7 +169,7 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT app.DebugPrintf("\tversion=%d.\n", version); for (int i = 0; i < 8; i++) dis.readByte(); - + BYTE compression_type = dis.readByte(); app.DebugPrintf("\tcompressionType=%d.\n", compression_type); @@ -179,11 +179,11 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT decomp_len = dis.readInt(); app.DebugPrintf("\tcompr_len=%d.\n\tdecomp_len=%d.\n", compr_len, decomp_len); - + // Decompress File Body - byteArray content(new BYTE[decomp_len], decomp_len), + byteArray content(new BYTE[decomp_len], decomp_len), compr_content(new BYTE[compr_len], compr_len); dis.read(compr_content); @@ -256,7 +256,7 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize) // Initialise output stream. ByteArrayOutputStream baos; DataOutputStream dos(&baos); - + // Write header. // VERSION NUMBER @@ -284,7 +284,7 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize) compr_dos.writeInt( 0 ); // XmlObjects.length } else - { + { StringTable *st = m_currentGameRuleDefinitions->getStringTable(); if (st == NULL) @@ -316,9 +316,9 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize) dos.writeInt( compr_ba.length ); // Write length dos.writeInt( compr_baos.buf.length ); dos.write(compr_ba); - + delete [] compr_ba.data; - + compr_dos.close(); compr_baos.close(); // -- END COMPRESSED -- // @@ -328,7 +328,7 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize) *dOut = baos.buf.data; baos.buf.data = NULL; - + dos.close(); baos.close(); } @@ -383,7 +383,7 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT //DWORD dwLen = 0; //PBYTE pbData = dlcFile->getData(dwLen); //byteArray data(pbData,dwLen); - + byteArray data(dIn, dSize); ByteArrayInputStream bais(data); DataInputStream dis(&bais); @@ -391,7 +391,7 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT // Read File. // version_number - __int64 version = dis.readShort(); + int64_t version = dis.readShort(); unsigned char compressionType = 0; if(version == 0) { @@ -502,7 +502,7 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT } }*/ - // subfile + // subfile UINT numFiles = contentDis->readInt(); for (UINT i = 0; i < numFiles; i++) { @@ -570,10 +570,10 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT LevelGenerationOptions *GameRuleManager::readHeader(DLCGameRulesHeader *grh) { - LevelGenerationOptions *out = + LevelGenerationOptions *out = new LevelGenerationOptions(); - + out->setSrc(LevelGenerationOptions::eSrc_fromDLC); out->setGrSource(grh); addLevelGenerationOptions(out); @@ -733,7 +733,7 @@ LPCWSTR GameRuleManager::GetGameRulesString(const wstring &key) LEVEL_GEN_ID GameRuleManager::addLevelGenerationOptions(LevelGenerationOptions *lgo) { vector *lgs = m_levelGenerators.getLevelGenerators(); - + for (int i = 0; isize(); i++) if (lgs->at(i) == lgo) return i; @@ -753,7 +753,7 @@ void GameRuleManager::unloadCurrentGameRules() if (m_currentLevelGenerationOptions->isFromSave()) { m_levelGenerators.removeLevelGenerator( m_currentLevelGenerationOptions ); - + delete m_currentLevelGenerationOptions; } else if (m_currentLevelGenerationOptions->isFromDLC()) diff --git a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp index 717b066e..a36d8549 100644 --- a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp +++ b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp @@ -70,17 +70,17 @@ LevelGenerationOptions::~LevelGenerationOptions() { delete *it; } - + for(AUTO_VAR(it, m_biomeOverrides.begin()); it != m_biomeOverrides.end(); ++it) { delete *it; } - + for(AUTO_VAR(it, m_features.begin()); it != m_features.end(); ++it) { delete *it; } - + if (m_stringTable) if (!isTutorial()) delete m_stringTable; @@ -93,7 +93,7 @@ ConsoleGameRules::EGameRuleType LevelGenerationOptions::getActionType() { return void LevelGenerationOptions::writeAttributes(DataOutputStream *dos, UINT numAttrs) { GameRuleDefinition::writeAttributes(dos, numAttrs + 5); - + ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnX); dos->writeUTF(_toString(m_spawnPos->x)); ConsoleGameRules::write(dos, ConsoleGameRules::eGameRuleAttr_spawnY); @@ -110,12 +110,12 @@ void LevelGenerationOptions::writeAttributes(DataOutputStream *dos, UINT numAttr void LevelGenerationOptions::getChildren(vector *children) { GameRuleDefinition::getChildren(children); - + vector used_schematics; for (AUTO_VAR(it, m_schematicRules.begin()); it != m_schematicRules.end(); it++) if ( !(*it)->isComplete() ) used_schematics.push_back( *it ); - + for(AUTO_VAR(it, m_structureRules.begin()); it!=m_structureRules.end(); it++) children->push_back( *it ); for(AUTO_VAR(it, used_schematics.begin()); it!=used_schematics.end(); it++) @@ -162,7 +162,7 @@ void LevelGenerationOptions::addAttribute(const wstring &attributeName, const ws { if(attributeName.compare(L"seed") == 0) { - m_seed = _fromString<__int64>(attributeValue); + m_seed = _fromString(attributeValue); app.DebugPrintf("LevelGenerationOptions: Adding parameter m_seed=%I64d\n",m_seed); } else if(attributeName.compare(L"spawnX") == 0) @@ -213,7 +213,7 @@ void LevelGenerationOptions::addAttribute(const wstring &attributeName, const ws app.DebugPrintf("LevelGenerationOptions: Adding parameter displayName=%ls\n", getDisplayName()); } else if(attributeName.compare(L"texturePackId") == 0) - { + { setRequiredTexturePackId( _fromString(attributeValue) ); setRequiresTexturePack( true ); app.DebugPrintf("LevelGenerationOptions: Adding parameter texturePackId=%0x\n", getRequiredTexturePackId()); @@ -290,14 +290,14 @@ bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1, int for( AUTO_VAR(it, m_structureRules.begin()); it != m_structureRules.end(); it++ ) { - ConsoleGenerateStructure *structureStart = *it; + ConsoleGenerateStructure *structureStart = *it; int minY = structureStart->getMinY(); if(minY < m_minY) m_minY = minY; } m_bHaveMinY = true; } - + // 4J Stu - We DO NOT intersect if our upper bound is below the lower bound for all schematics if( y1 < m_minY ) return false; @@ -313,7 +313,7 @@ bool LevelGenerationOptions::checkIntersects(int x0, int y0, int z0, int x1, int { for( AUTO_VAR(it, m_structureRules.begin()); it != m_structureRules.end(); it++ ) { - ConsoleGenerateStructure *structureStart = *it; + ConsoleGenerateStructure *structureStart = *it; intersects = structureStart->checkIntersects(x0,y0,z0,x1,y1,z1); if(intersects) break; } @@ -438,12 +438,12 @@ unordered_map *LevelGenerationOptions::getUnfin usedFiles.insert( (*it)->getSchematicName() ); // Clean schematic files. - unordered_map *out + unordered_map *out = new unordered_map(); for (AUTO_VAR(it, usedFiles.begin()); it!=usedFiles.end(); it++) out->insert( pair(*it, getSchematicFile(*it)) ); - - return out; + + return out; } void LevelGenerationOptions::reset_start() @@ -505,7 +505,7 @@ void LevelGenerationOptions::deleteBaseSaveData() { if(m_pbBaseSaveData) delete bool LevelGenerationOptions::hasLoadedData() { return m_hasLoadedData; } void LevelGenerationOptions::setLoadedData() { m_hasLoadedData = true; } -__int64 LevelGenerationOptions::getLevelSeed() { return m_seed; } +int64_t LevelGenerationOptions::getLevelSeed() { return m_seed; } Pos *LevelGenerationOptions::getSpawnPos() { return m_spawnPos; } bool LevelGenerationOptions::getuseFlatWorld() { return m_useFlatWorld; } diff --git a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.h b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.h index 0cc9da79..6ae6f033 100644 --- a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.h +++ b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.h @@ -19,7 +19,7 @@ class GrSource public: // 4J-JEV: // Moved all this here; I didn't like that all this header information - // was being mixed in with all the game information as they have + // was being mixed in with all the game information as they have // completely different lifespans. virtual bool requiresTexturePack()=0; @@ -146,7 +146,7 @@ public: private: // This should match the "MapOptionsRule" definition in the XML schema - __int64 m_seed; + int64_t m_seed; bool m_useFlatWorld; Pos *m_spawnPos; vector m_schematicRules; @@ -167,13 +167,13 @@ public: ~LevelGenerationOptions(); virtual ConsoleGameRules::EGameRuleType getActionType(); - + virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes); virtual void getChildren(vector *children); virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType); virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue); - __int64 getLevelSeed(); + int64_t getLevelSeed(); Pos *getSpawnPos(); bool getuseFlatWorld(); @@ -185,7 +185,7 @@ public: private: void clearSchematics(); -public: +public: ConsoleSchematicFile *loadSchematicFile(const wstring &filename, PBYTE pbData, DWORD dwLen); public: @@ -203,7 +203,7 @@ public: LPCWSTR getString(const wstring &key); unordered_map *getUnfinishedSchematicFiles(); - + // 4J-JEV: // ApplySchematicRules contain limited state // which needs to be reset BEFORE a new game starts. -- cgit v1.2.3