aboutsummaryrefslogtreecommitdiff
path: root/Minecraft.Client/Common/GameRules
diff options
context:
space:
mode:
authorqwasdrizzel <145519042+qwasdrizzel@users.noreply.github.com>2026-03-16 21:44:26 -0500
committerGitHub <noreply@github.com>2026-03-16 21:44:26 -0500
commitce739f6045ec72127491286ea3f3f21e537c1b55 (patch)
treef33bd42a47c1b4a7b2153a7fb77127ee3b407db9 /Minecraft.Client/Common/GameRules
parent255a18fe8e9b57377975f82e2b227afe2a12eda0 (diff)
parent5a59f5d146b43811dde6a5a0245ee9875d7b5cd1 (diff)
Merge branch 'smartcmd:main' into main
Diffstat (limited to 'Minecraft.Client/Common/GameRules')
-rw-r--r--Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp4
-rw-r--r--Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp10
-rw-r--r--Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp32
-rw-r--r--Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.h8
-rw-r--r--Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp26
-rw-r--r--Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp10
-rw-r--r--Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp8
-rw-r--r--Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp22
-rw-r--r--Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h2
-rw-r--r--Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp100
-rw-r--r--Minecraft.Client/Common/GameRules/ConsoleSchematicFile.h6
-rw-r--r--Minecraft.Client/Common/GameRules/GameRule.h6
-rw-r--r--Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp2
-rw-r--r--Minecraft.Client/Common/GameRules/GameRuleDefinition.h2
-rw-r--r--Minecraft.Client/Common/GameRules/GameRuleManager.cpp112
-rw-r--r--Minecraft.Client/Common/GameRules/GameRuleManager.h4
-rw-r--r--Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp141
-rw-r--r--Minecraft.Client/Common/GameRules/LevelGenerationOptions.h16
-rw-r--r--Minecraft.Client/Common/GameRules/LevelRuleset.cpp8
-rw-r--r--Minecraft.Client/Common/GameRules/StartFeature.cpp4
-rw-r--r--Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp16
-rw-r--r--Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp8
-rw-r--r--Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp4
23 files changed, 324 insertions, 227 deletions
diff --git a/Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp
index 555ed8b4..f97bfdd1 100644
--- a/Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp
+++ b/Minecraft.Client/Common/GameRules/AddEnchantmentRuleDefinition.cpp
@@ -46,7 +46,7 @@ void AddEnchantmentRuleDefinition::addAttribute(const wstring &attributeName, co
bool AddEnchantmentRuleDefinition::enchantItem(shared_ptr<ItemInstance> item)
{
bool enchanted = false;
- if (item != NULL)
+ if (item != nullptr)
{
// 4J-JEV: Ripped code from enchantmenthelpers
// Maybe we want to add an addEnchantment method to EnchantmentHelpers
@@ -58,7 +58,7 @@ bool AddEnchantmentRuleDefinition::enchantItem(shared_ptr<ItemInstance> item)
{
Enchantment *e = Enchantment::enchantments[m_enchantmentId];
- if(e != NULL && e->category->canEnchant(item->getItem()))
+ if(e != nullptr && e->category->canEnchant(item->getItem()))
{
int level = min(e->getMaxLevel(), m_enchantmentLevel);
item->enchant(e, m_enchantmentLevel);
diff --git a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp
index 801a2937..49809d0c 100644
--- a/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp
+++ b/Minecraft.Client/Common/GameRules/AddItemRuleDefinition.cpp
@@ -41,11 +41,11 @@ void AddItemRuleDefinition::getChildren(vector<GameRuleDefinition *> *children)
GameRuleDefinition *AddItemRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
- GameRuleDefinition *rule = NULL;
+ GameRuleDefinition *rule = nullptr;
if(ruleType == ConsoleGameRules::eGameRuleType_AddEnchantment)
{
rule = new AddEnchantmentRuleDefinition();
- m_enchantments.push_back((AddEnchantmentRuleDefinition *)rule);
+ m_enchantments.push_back(static_cast<AddEnchantmentRuleDefinition *>(rule));
}
else
{
@@ -97,10 +97,10 @@ void AddItemRuleDefinition::addAttribute(const wstring &attributeName, const wst
bool AddItemRuleDefinition::addItemToContainer(shared_ptr<Container> container, int slotId)
{
bool added = false;
- if(Item::items[m_itemId] != NULL)
+ if(Item::items[m_itemId] != nullptr)
{
int quantity = std::min<int>(m_quantity, Item::items[m_itemId]->getMaxStackSize());
- shared_ptr<ItemInstance> newItem = shared_ptr<ItemInstance>(new ItemInstance(m_itemId,quantity,m_auxValue) );
+ shared_ptr<ItemInstance> newItem = std::make_shared<ItemInstance>(m_itemId, quantity, m_auxValue);
newItem->set4JData(m_dataTag);
for( auto& it : m_enchantments )
@@ -118,7 +118,7 @@ bool AddItemRuleDefinition::addItemToContainer(shared_ptr<Container> container,
container->setItem( slotId, newItem );
added = true;
}
- else if(dynamic_pointer_cast<Inventory>(container) != NULL)
+ else if(dynamic_pointer_cast<Inventory>(container) != nullptr)
{
added = dynamic_pointer_cast<Inventory>(container)->add(newItem);
}
diff --git a/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp
index a740a2be..3c7e02a3 100644
--- a/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp
+++ b/Minecraft.Client/Common/GameRules/ApplySchematicRuleDefinition.cpp
@@ -13,20 +13,20 @@ ApplySchematicRuleDefinition::ApplySchematicRuleDefinition(LevelGenerationOption
{
m_levelGenOptions = levelGenOptions;
m_location = Vec3::newPermanent(0,0,0);
- m_locationBox = NULL;
+ m_locationBox = nullptr;
m_totalBlocksChanged = 0;
m_totalBlocksChangedLighting = 0;
m_rotation = ConsoleSchematicFile::eSchematicRot_0;
m_completed = false;
m_dimension = 0;
- m_schematic = NULL;
+ m_schematic = nullptr;
}
ApplySchematicRuleDefinition::~ApplySchematicRuleDefinition()
{
app.DebugPrintf("Deleting ApplySchematicRuleDefinition.\n");
if(!m_completed) m_levelGenOptions->releaseSchematicFile(m_schematicName);
- m_schematic = NULL;
+ m_schematic = nullptr;
delete m_location;
}
@@ -72,20 +72,20 @@ void ApplySchematicRuleDefinition::addAttribute(const wstring &attributeName, co
else if(attributeName.compare(L"x") == 0)
{
m_location->x = _fromString<int>(attributeValue);
- if( ((int)abs(m_location->x))%2 != 0) m_location->x -=1;
+ if( static_cast<int>(abs(m_location->x))%2 != 0) m_location->x -=1;
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter x=%f\n",m_location->x);
}
else if(attributeName.compare(L"y") == 0)
{
m_location->y = _fromString<int>(attributeValue);
- if( ((int)abs(m_location->y))%2 != 0) m_location->y -= 1;
+ if( static_cast<int>(abs(m_location->y))%2 != 0) m_location->y -= 1;
if(m_location->y < 0) m_location->y = 0;
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter y=%f\n",m_location->y);
}
else if(attributeName.compare(L"z") == 0)
{
m_location->z = _fromString<int>(attributeValue);
- if(((int)abs(m_location->z))%2 != 0) m_location->z -= 1;
+ if(static_cast<int>(abs(m_location->z))%2 != 0) m_location->z -= 1;
//app.DebugPrintf("ApplySchematicRuleDefinition: Adding parameter z=%f\n",m_location->z);
}
else if(attributeName.compare(L"rot") == 0)
@@ -95,7 +95,7 @@ void ApplySchematicRuleDefinition::addAttribute(const wstring &attributeName, co
while(degrees < 0) degrees += 360;
while(degrees >= 360) degrees -= 360;
float quad = degrees/90;
- degrees = (int)(quad + 0.5f);
+ degrees = static_cast<int>(quad + 0.5f);
switch(degrees)
{
case 1:
@@ -130,7 +130,7 @@ void ApplySchematicRuleDefinition::addAttribute(const wstring &attributeName, co
void ApplySchematicRuleDefinition::updateLocationBox()
{
- if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
+ if(m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
m_locationBox = AABB::newPermanent(0,0,0,0,0,0);
@@ -162,9 +162,9 @@ void ApplySchematicRuleDefinition::processSchematic(AABB *chunkBox, LevelChunk *
if(chunk->level->dimension->id != m_dimension) return;
PIXBeginNamedEvent(0, "Processing ApplySchematicRuleDefinition");
- if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
+ if(m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
- if(m_locationBox == NULL) updateLocationBox();
+ if(m_locationBox == nullptr) updateLocationBox();
if(chunkBox->intersects( m_locationBox ))
{
m_locationBox->y1 = min((double)Level::maxBuildHeight, m_locationBox->y1 );
@@ -189,7 +189,7 @@ void ApplySchematicRuleDefinition::processSchematic(AABB *chunkBox, LevelChunk *
{
m_completed = true;
//m_levelGenOptions->releaseSchematicFile(m_schematicName);
- //m_schematic = NULL;
+ //m_schematic = nullptr;
}
}
PIXEndNamedEvent();
@@ -201,9 +201,9 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB *chunkBox, Leve
if(chunk->level->dimension->id != m_dimension) return;
PIXBeginNamedEvent(0, "Processing ApplySchematicRuleDefinition (lighting)");
- if(m_schematic == NULL) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
+ if(m_schematic == nullptr) m_schematic = m_levelGenOptions->getSchematicFile(m_schematicName);
- if(m_locationBox == NULL) updateLocationBox();
+ if(m_locationBox == nullptr) updateLocationBox();
if(chunkBox->intersects( m_locationBox ))
{
m_locationBox->y1 = min((double)Level::maxBuildHeight, m_locationBox->y1 );
@@ -223,7 +223,7 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB *chunkBox, Leve
{
m_completed = true;
//m_levelGenOptions->releaseSchematicFile(m_schematicName);
- //m_schematic = NULL;
+ //m_schematic = nullptr;
}
}
PIXEndNamedEvent();
@@ -231,13 +231,13 @@ void ApplySchematicRuleDefinition::processSchematicLighting(AABB *chunkBox, Leve
bool ApplySchematicRuleDefinition::checkIntersects(int x0, int y0, int z0, int x1, int y1, int z1)
{
- if( m_locationBox == NULL ) updateLocationBox();
+ if( m_locationBox == nullptr ) updateLocationBox();
return m_locationBox->intersects(x0,y0,z0,x1,y1,z1);
}
int ApplySchematicRuleDefinition::getMinY()
{
- if( m_locationBox == NULL ) updateLocationBox();
+ if( m_locationBox == nullptr ) updateLocationBox();
return m_locationBox->y0;
}
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/CollectItemRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp
index f3b48445..7f03a0fe 100644
--- a/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp
+++ b/Minecraft.Client/Common/GameRules/CollectItemRuleDefinition.cpp
@@ -77,7 +77,7 @@ void CollectItemRuleDefinition::populateGameRule(GameRulesInstance::EGameRulesIn
bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemInstance> item)
{
bool statusChanged = false;
- if(item != NULL && item->id == m_itemId && item->getAuxValue() == m_auxValue && item->get4JData() == m_4JDataValue)
+ if(item != nullptr && item->id == m_itemId && item->getAuxValue() == m_auxValue && item->get4JData() == m_4JDataValue)
{
if(!getComplete(rule))
{
@@ -90,13 +90,21 @@ bool CollectItemRuleDefinition::onCollectItem(GameRule *rule, shared_ptr<ItemIns
if(quantityCollected >= m_quantity)
{
setComplete(rule, true);
- app.DebugPrintf("Completed CollectItemRule with info - itemId:%d, auxValue:%d, quantity:%d, dataTag:%d\n", m_itemId,m_auxValue,m_quantity,m_4JDataValue);
-
- if(rule->getConnection() != NULL)
- {
- rule->getConnection()->send( shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId, m_itemId, m_auxValue, this->m_4JDataValue,NULL,0)));
- }
- }
+ app.DebugPrintf("Completed CollectItemRule with info - itemId:%d, auxValue:%d, quantity:%d, dataTag:%d\n", m_itemId, m_auxValue, m_quantity, m_4JDataValue);
+
+ if (rule->getConnection() != nullptr)
+ {
+ rule->getConnection()->send(std::make_shared<UpdateGameRuleProgressPacket>(
+ getActionType(),
+ this->m_descriptionId,
+ m_itemId,
+ m_auxValue,
+ this->m_4JDataValue,
+ nullptr,
+ static_cast<DWORD>(0)
+ ));
+ }
+ }
}
}
return statusChanged;
@@ -106,7 +114,7 @@ wstring CollectItemRuleDefinition::generateXml(shared_ptr<ItemInstance> item)
{
// 4J Stu - This should be kept in sync with the GameRulesDefinition.xsd
wstring xml = L"";
- if(item != NULL)
+ if(item != nullptr)
{
xml = L"<CollectItemRule itemId=\"" + std::to_wstring(item->id) + L"\" quantity=\"SET\" descriptionName=\"OPTIONAL\" promptName=\"OPTIONAL\"";
if(item->getAuxValue() != 0) xml += L" auxValue=\"" + std::to_wstring(item->getAuxValue()) + L"\"";
diff --git a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp
index b928b26c..cd23cd50 100644
--- a/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp
+++ b/Minecraft.Client/Common/GameRules/CompleteAllRuleDefinition.cpp
@@ -36,7 +36,7 @@ void CompleteAllRuleDefinition::updateStatus(GameRule *rule)
progress += it.second.gr->getGameRuleDefinition()->getProgress(it.second.gr);
}
}
- if(rule->getConnection() != NULL)
+ if(rule->getConnection() != nullptr)
{
PacketData data;
data.goal = goal;
@@ -45,20 +45,20 @@ void CompleteAllRuleDefinition::updateStatus(GameRule *rule)
int icon = -1;
int auxValue = 0;
- if(m_lastRuleStatusChanged != NULL)
+ if(m_lastRuleStatusChanged != nullptr)
{
icon = m_lastRuleStatusChanged->getIcon();
auxValue = m_lastRuleStatusChanged->getAuxValue();
- m_lastRuleStatusChanged = NULL;
+ m_lastRuleStatusChanged = nullptr;
}
- rule->getConnection()->send( shared_ptr<UpdateGameRuleProgressPacket>( new UpdateGameRuleProgressPacket(getActionType(), this->m_descriptionId,icon, auxValue, 0,&data,sizeof(PacketData))));
+ rule->getConnection()->send(std::make_shared<UpdateGameRuleProgressPacket>(getActionType(), this->m_descriptionId, icon, auxValue, 0, &data, sizeof(PacketData)));
}
app.DebugPrintf("Updated CompleteAllRule - Completed %d of %d\n", progress, goal);
}
wstring CompleteAllRuleDefinition::generateDescriptionString(const wstring &description, void *data, int dataLength)
{
- PacketData *values = (PacketData *)data;
+ PacketData *values = static_cast<PacketData *>(data);
wstring newDesc = description;
newDesc = replaceAll(newDesc,L"{*progress*}",std::to_wstring(values->progress));
newDesc = replaceAll(newDesc,L"{*goal*}",std::to_wstring(values->goal));
diff --git a/Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp
index 395b4eeb..f75eddd4 100644
--- a/Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp
+++ b/Minecraft.Client/Common/GameRules/CompoundGameRuleDefinition.cpp
@@ -6,7 +6,7 @@
CompoundGameRuleDefinition::CompoundGameRuleDefinition()
{
- m_lastRuleStatusChanged = NULL;
+ m_lastRuleStatusChanged = nullptr;
}
CompoundGameRuleDefinition::~CompoundGameRuleDefinition()
@@ -26,7 +26,7 @@ void CompoundGameRuleDefinition::getChildren(vector<GameRuleDefinition *> *child
GameRuleDefinition *CompoundGameRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
- GameRuleDefinition *rule = NULL;
+ GameRuleDefinition *rule = nullptr;
if(ruleType == ConsoleGameRules::eGameRuleType_CompleteAllRule)
{
rule = new CompleteAllRuleDefinition();
@@ -49,13 +49,13 @@ GameRuleDefinition *CompoundGameRuleDefinition::addChild(ConsoleGameRules::EGame
wprintf(L"CompoundGameRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType );
#endif
}
- if(rule != NULL) m_children.push_back(rule);
+ if(rule != nullptr) m_children.push_back(rule);
return rule;
}
void CompoundGameRuleDefinition::populateGameRule(GameRulesInstance::EGameRulesInstanceType type, GameRule *rule)
{
- GameRule *newRule = NULL;
+ GameRule *newRule = nullptr;
int i = 0;
for (auto& it : m_children )
{
diff --git a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp
index f505ce7a..dd777682 100644
--- a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp
+++ b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.cpp
@@ -10,7 +10,7 @@
ConsoleGenerateStructure::ConsoleGenerateStructure() : StructurePiece(0)
{
m_x = m_y = m_z = 0;
- boundingBox = NULL;
+ boundingBox = nullptr;
orientation = Direction::NORTH;
m_dimension = 0;
}
@@ -25,26 +25,26 @@ void ConsoleGenerateStructure::getChildren(vector<GameRuleDefinition *> *childre
GameRuleDefinition *ConsoleGenerateStructure::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
- GameRuleDefinition *rule = NULL;
+ GameRuleDefinition *rule = nullptr;
if(ruleType == ConsoleGameRules::eGameRuleType_GenerateBox)
{
rule = new XboxStructureActionGenerateBox();
- m_actions.push_back((XboxStructureActionGenerateBox *)rule);
+ m_actions.push_back(static_cast<XboxStructureActionGenerateBox *>(rule));
}
else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceBlock)
{
rule = new XboxStructureActionPlaceBlock();
- m_actions.push_back((XboxStructureActionPlaceBlock *)rule);
+ m_actions.push_back(static_cast<XboxStructureActionPlaceBlock *>(rule));
}
else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceContainer)
{
rule = new XboxStructureActionPlaceContainer();
- m_actions.push_back((XboxStructureActionPlaceContainer *)rule);
+ m_actions.push_back(static_cast<XboxStructureActionPlaceContainer *>(rule));
}
else if(ruleType == ConsoleGameRules::eGameRuleType_PlaceSpawner)
{
rule = new XboxStructureActionPlaceSpawner();
- m_actions.push_back((XboxStructureActionPlaceSpawner *)rule);
+ m_actions.push_back(static_cast<XboxStructureActionPlaceSpawner *>(rule));
}
else
{
@@ -112,7 +112,7 @@ void ConsoleGenerateStructure::addAttribute(const wstring &attributeName, const
BoundingBox* ConsoleGenerateStructure::getBoundingBox()
{
- if(boundingBox == NULL)
+ if(boundingBox == nullptr)
{
// Find the max bounds
int maxX, maxY, maxZ;
@@ -139,25 +139,25 @@ bool ConsoleGenerateStructure::postProcess(Level *level, Random *random, Boundin
{
case ConsoleGameRules::eGameRuleType_GenerateBox:
{
- XboxStructureActionGenerateBox *genBox = (XboxStructureActionGenerateBox *)action;
+ XboxStructureActionGenerateBox *genBox = static_cast<XboxStructureActionGenerateBox *>(action);
genBox->generateBoxInLevel(this,level,chunkBB);
}
break;
case ConsoleGameRules::eGameRuleType_PlaceBlock:
{
- XboxStructureActionPlaceBlock *pPlaceBlock = (XboxStructureActionPlaceBlock *)action;
+ XboxStructureActionPlaceBlock *pPlaceBlock = static_cast<XboxStructureActionPlaceBlock *>(action);
pPlaceBlock->placeBlockInLevel(this,level,chunkBB);
}
break;
case ConsoleGameRules::eGameRuleType_PlaceContainer:
{
- XboxStructureActionPlaceContainer *pPlaceContainer = (XboxStructureActionPlaceContainer *)action;
+ XboxStructureActionPlaceContainer *pPlaceContainer = static_cast<XboxStructureActionPlaceContainer *>(action);
pPlaceContainer->placeContainerInLevel(this,level,chunkBB);
}
break;
case ConsoleGameRules::eGameRuleType_PlaceSpawner:
{
- XboxStructureActionPlaceSpawner *pPlaceSpawner = (XboxStructureActionPlaceSpawner *)action;
+ XboxStructureActionPlaceSpawner *pPlaceSpawner = static_cast<XboxStructureActionPlaceSpawner *>(action);
pPlaceSpawner->placeSpawnerInLevel(this,level,chunkBB);
}
break;
diff --git a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h
index 91c4ef35..712a29ab 100644
--- a/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h
+++ b/Minecraft.Client/Common/GameRules/ConsoleGenerateStructure.h
@@ -36,7 +36,7 @@ public:
virtual int getMinY();
- EStructurePiece GetType() { return (EStructurePiece)0; }
+ EStructurePiece GetType() { return static_cast<EStructurePiece>(0); }
void addAdditonalSaveData(CompoundTag *tag) {}
void readAdditonalSaveData(CompoundTag *tag) {}
}; \ No newline at end of file
diff --git a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp
index 01a8119e..c261e0cd 100644
--- a/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp
+++ b/Minecraft.Client/Common/GameRules/ConsoleSchematicFile.cpp
@@ -16,18 +16,18 @@ ConsoleSchematicFile::ConsoleSchematicFile()
{
m_xSize = m_ySize = m_zSize = 0;
m_refCount = 1;
- m_data.data = NULL;
+ m_data.data = nullptr;
}
ConsoleSchematicFile::~ConsoleSchematicFile()
{
app.DebugPrintf("Deleting schematic file\n");
- if(m_data.data != NULL) delete [] m_data.data;
+ if(m_data.data != nullptr) delete [] m_data.data;
}
void ConsoleSchematicFile::save(DataOutputStream *dos)
{
- if(dos != NULL)
+ if(dos != nullptr)
{
dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION);
@@ -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);
@@ -52,7 +52,7 @@ void ConsoleSchematicFile::save(DataOutputStream *dos)
void ConsoleSchematicFile::load(DataInputStream *dis)
{
- if(dis != NULL)
+ if(dis != nullptr)
{
// VERSION CHECK //
int version = dis->readInt();
@@ -61,7 +61,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
if (version > XBOX_SCHEMATIC_ORIGINAL_VERSION) // Or later versions
{
- compressionType = (Compression::ECompressionTypes)dis->readByte();
+ compressionType = static_cast<Compression::ECompressionTypes>(dis->readByte());
}
if (version > XBOX_SCHEMATIC_CURRENT_VERSION)
@@ -71,14 +71,14 @@ 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)
+ if(m_data.data != nullptr)
{
delete [] m_data.data;
- m_data.data = NULL;
+ m_data.data = nullptr;
}
if(compressionType == Compression::eCompressionType_None)
@@ -111,17 +111,17 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
// READ TAGS //
CompoundTag *tag = NbtIo::read(dis);
ListTag<CompoundTag> *tileEntityTags = (ListTag<CompoundTag> *) tag->getList(L"TileEntities");
- if (tileEntityTags != NULL)
+ if (tileEntityTags != nullptr)
{
for (int i = 0; i < tileEntityTags->size(); i++)
{
CompoundTag *teTag = tileEntityTags->get(i);
shared_ptr<TileEntity> te = TileEntity::loadStatic(teTag);
- if(te == NULL)
+ if(te == nullptr)
{
#ifndef _CONTENT_PACKAGE
- app.DebugPrintf("ConsoleSchematicFile has read a NULL tile entity\n");
+ app.DebugPrintf("ConsoleSchematicFile has read a nullptr tile entity\n");
__debugbreak();
#endif
}
@@ -132,7 +132,7 @@ void ConsoleSchematicFile::load(DataInputStream *dis)
}
}
ListTag<CompoundTag> *entityTags = (ListTag<CompoundTag> *) tag->getList(L"Entities");
- if (entityTags != NULL)
+ if (entityTags != nullptr)
{
for (int i = 0; i < entityTags->size(); i++)
{
@@ -145,15 +145,15 @@ 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;
- }
+ {
+ x = static_cast<IntTag *>(eTag->get(L"TileX"))->data;
+ y = static_cast<IntTag *>(eTag->get(L"TileY"))->data;
+ z = static_cast<IntTag *>(eTag->get(L"TileZ"))->data;
+ }
#ifdef _DEBUG
//app.DebugPrintf(1,"Loaded entity type %d at (%f,%f,%f)\n",(int)type,x,y,z);
#endif
- m_entities.push_back( pair<Vec3 *, CompoundTag *>(Vec3::newPermanent(x,y,z),(CompoundTag *)eTag->copy()));
+ m_entities.push_back( pair<Vec3 *, CompoundTag *>(Vec3::newPermanent(x,y,z),static_cast<CompoundTag *>(eTag->copy())));
}
}
delete tag;
@@ -178,23 +178,23 @@ void ConsoleSchematicFile::save_tags(DataOutputStream *dos)
tag->put(L"Entities", entityTags);
for (auto& it : m_entities )
- entityTags->add( (CompoundTag *)(it).second->copy() );
+ entityTags->add( static_cast<CompoundTag *>((it).second->copy()) );
NbtIo::write(tag,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 = static_cast<int>(std::fmax<double>(destinationBox->x0, (double)chunk->x*16));
- int xEnd = static_cast<int>(std::fmin<double>(destinationBox->x1, (double)((xStart >> 4) << 4) + 16));
+ int xStart = static_cast<int>(std::fmax<double>(destinationBox->x0, static_cast<double>(chunk->x)*16));
+ int xEnd = static_cast<int>(std::fmin<double>(destinationBox->x1, static_cast<double>((xStart >> 4) << 4) + 16));
int yStart = destinationBox->y0;
int yEnd = destinationBox->y1;
if(yEnd > Level::maxBuildHeight) yEnd = Level::maxBuildHeight;
- int zStart = static_cast<int>(std::fmax<double>(destinationBox->z0, (double)chunk->z * 16));
- int zEnd = static_cast<int>(std::fmin<double>(destinationBox->z1, (double)((zStart >> 4) << 4) + 16));
+ int zStart = static_cast<int>(std::fmax<double>(destinationBox->z0, static_cast<double>(chunk->z) * 16));
+ int zEnd = static_cast<int>(std::fmin<double>(destinationBox->z1, static_cast<double>((zStart >> 4) << 4) + 16));
#ifdef _DEBUG
app.DebugPrintf("Range is (%d,%d,%d) to (%d,%d,%d)\n",xStart,yStart,zStart,xEnd-1,yEnd-1,zEnd-1);
@@ -281,7 +281,7 @@ __int64 ConsoleSchematicFile::applyBlocksAndData(LevelChunk *chunk, AABB *chunkB
// blockData[i] = Tile::endStone_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);
@@ -442,9 +442,9 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox,
Vec3 *pos = Vec3::newTemp(targetX,targetY,targetZ);
if( chunkBox->containsIncludingLowerBound(pos) )
{
- shared_ptr<TileEntity> teCopy = chunk->getTileEntity( (int)targetX & 15, (int)targetY & 15, (int)targetZ & 15 );
+ shared_ptr<TileEntity> teCopy = chunk->getTileEntity( static_cast<int>(targetX) & 15, static_cast<int>(targetY) & 15, static_cast<int>(targetZ) & 15 );
- if ( teCopy != NULL )
+ if ( teCopy != nullptr )
{
CompoundTag *teData = new CompoundTag();
te->save(teData);
@@ -478,7 +478,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox,
for (auto 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;
@@ -493,12 +493,12 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox,
}
CompoundTag *eTag = it->second;
- shared_ptr<Entity> e = EntityIO::loadStatic(eTag, NULL);
+ shared_ptr<Entity> e = EntityIO::loadStatic(eTag, nullptr);
if( e->GetType() == eTYPE_PAINTING )
{
shared_ptr<Painting> painting = dynamic_pointer_cast<Painting>(e);
-
+
double tileX = painting->xTile;
double tileZ = painting->zTile;
schematicCoordToChunkCoord(destinationBox, painting->xTile, painting->zTile, rot, tileX, tileZ);
@@ -511,7 +511,7 @@ void ConsoleSchematicFile::applyTileEntities(LevelChunk *chunk, AABB *chunkBox,
else if( e->GetType() == eTYPE_ITEM_FRAME )
{
shared_ptr<ItemFrame> frame = dynamic_pointer_cast<ItemFrame>(e);
-
+
double tileX = frame->xTile;
double tileZ = frame->zTile;
schematicCoordToChunkCoord(destinationBox, frame->xTile, frame->zTile, rot, tileX, tileZ);
@@ -559,7 +559,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;
@@ -582,18 +582,18 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l
app.DebugPrintf("Generating schematic file for area (%d,%d,%d) to (%d,%d,%d), %dx%dx%d\n",xStart,yStart,zStart,xEnd,yEnd,zEnd,xSize,ySize,zSize);
- if(dos != NULL) dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION);
+ if(dos != nullptr) dos->writeInt(XBOX_SCHEMATIC_CURRENT_VERSION);
- if(dos != NULL) dos->writeByte(compressionType);
+ if(dos != nullptr) dos->writeByte(compressionType);
//Write xSize
- if(dos != NULL) dos->writeInt(xSize);
+ if(dos != nullptr) dos->writeInt(xSize);
//Write ySize
- if(dos != NULL) dos->writeInt(ySize);
+ if(dos != nullptr) dos->writeInt(ySize);
//Write zSize
- if(dos != NULL) dos->writeInt(zSize);
+ if(dos != nullptr) dos->writeInt(zSize);
//byteArray rawBuffer = level->getBlocksAndData(xStart, yStart, zStart, xSize, ySize, zSize, false);
int xRowSize = ySize * zSize;
@@ -613,7 +613,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;
@@ -622,7 +622,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;
@@ -660,8 +660,8 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l
delete [] result.data;
byteArray buffer = byteArray(ucTemp,inputSize);
- if(dos != NULL) dos->writeInt(inputSize);
- if(dos != NULL) dos->write(buffer);
+ if(dos != nullptr) dos->writeInt(inputSize);
+ if(dos != nullptr) dos->write(buffer);
delete [] buffer.data;
CompoundTag tag;
@@ -713,11 +713,11 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l
}
// 4J-JEV: Changed to check for instances of minecarts and hangingEntities instead of just eTYPE_PAINTING, eTYPE_ITEM_FRAME and eTYPE_MINECART
- if (mobCanBeSaved || e->instanceof(eTYPE_MINECART) || e->GetType() == eTYPE_BOAT || e->instanceof(eTYPE_HANGING_ENTITY))
+ if (mobCanBeSaved || e->instanceof(eTYPE_MINECART) || e->GetType() == eTYPE_BOAT || e->instanceof(eTYPE_HANGING_ENTITY))
{
CompoundTag *eTag = new CompoundTag();
if( e->save(eTag) )
- {
+ {
ListTag<DoubleTag> *pos = (ListTag<DoubleTag> *) eTag->getList(L"Pos");
pos->get(0)->data -= xStart;
@@ -726,9 +726,9 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l
if( e->instanceof(eTYPE_HANGING_ENTITY) )
{
- ((IntTag *) eTag->get(L"TileX") )->data -= xStart;
- ((IntTag *) eTag->get(L"TileY") )->data -= yStart;
- ((IntTag *) eTag->get(L"TileZ") )->data -= zStart;
+ static_cast<IntTag *>(eTag->get(L"TileX"))->data -= xStart;
+ static_cast<IntTag *>(eTag->get(L"TileY"))->data -= yStart;
+ static_cast<IntTag *>(eTag->get(L"TileZ"))->data -= zStart;
}
entitiesTag->add(eTag);
@@ -738,7 +738,7 @@ void ConsoleSchematicFile::generateSchematicFile(DataOutputStream *dos, Level *l
tag.put(L"Entities", entitiesTag);
- if(dos != NULL) NbtIo::write(&tag,dos);
+ if(dos != nullptr) NbtIo::write(&tag,dos);
}
void ConsoleSchematicFile::getBlocksAndData(LevelChunk *chunk, byteArray *data, int x0, int y0, int z0, int x1, int y1, int z1, int &blocksP, int &dataP, int &blockLightP, int &skyLightP)
@@ -766,7 +766,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<shared_ptr<TileEntity> > m_tileEntities;
vector< pair<Vec3 *, CompoundTag *> > 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..e35f1375 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;
@@ -40,11 +40,11 @@ public:
stringValueMapType m_parameters; // These are the members of this rule that maintain it's state
public:
- GameRule(GameRuleDefinition *definition, Connection *connection = NULL);
+ GameRule(GameRuleDefinition *definition, Connection *connection = nullptr);
virtual ~GameRule();
Connection *getConnection() { return m_connection; }
-
+
ValueType getParameter(const wstring &parameterName);
void setParameter(const wstring &parameterName,ValueType value);
GameRuleDefinition *getGameRuleDefinition();
diff --git a/Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp
index 80d02956..770b56d5 100644
--- a/Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp
+++ b/Minecraft.Client/Common/GameRules/GameRuleDefinition.cpp
@@ -50,7 +50,7 @@ GameRuleDefinition *GameRuleDefinition::addChild(ConsoleGameRules::EGameRuleType
#ifndef _CONTENT_PACKAGE
wprintf(L"GameRuleDefinition: Attempted to add invalid child rule - %d\n", ruleType );
#endif
- return NULL;
+ return nullptr;
}
void GameRuleDefinition::addAttribute(const wstring &attributeName, const wstring &attributeValue)
diff --git a/Minecraft.Client/Common/GameRules/GameRuleDefinition.h b/Minecraft.Client/Common/GameRules/GameRuleDefinition.h
index afec8fbc..4a2c43a1 100644
--- a/Minecraft.Client/Common/GameRules/GameRuleDefinition.h
+++ b/Minecraft.Client/Common/GameRules/GameRuleDefinition.h
@@ -61,6 +61,6 @@ public:
// Static functions
static GameRulesInstance *generateNewGameRulesInstance(GameRulesInstance::EGameRulesInstanceType type, LevelRuleset *rules, Connection *connection);
- static wstring generateDescriptionString(ConsoleGameRules::EGameRuleType defType, const wstring &description, void *data = NULL, int dataLength = 0);
+ static wstring generateDescriptionString(ConsoleGameRules::EGameRuleType defType, const wstring &description, void *data = nullptr, int dataLength = 0);
}; \ No newline at end of file
diff --git a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp
index f18aa7ae..95434c08 100644
--- a/Minecraft.Client/Common/GameRules/GameRuleManager.cpp
+++ b/Minecraft.Client/Common/GameRules/GameRuleManager.cpp
@@ -12,7 +12,7 @@
#include "ConsoleGameRules.h"
#include "GameRuleManager.h"
-WCHAR *GameRuleManager::wchTagNameA[] =
+const WCHAR *GameRuleManager::wchTagNameA[] =
{
L"", // eGameRuleType_Root
L"MapOptions", // eGameRuleType_LevelGenerationOptions
@@ -34,7 +34,7 @@ WCHAR *GameRuleManager::wchTagNameA[] =
L"UpdatePlayer", // eGameRuleType_UpdatePlayerRule
};
-WCHAR *GameRuleManager::wchAttrNameA[] =
+const WCHAR *GameRuleManager::wchAttrNameA[] =
{
L"descriptionName", // eGameRuleAttr_descriptionName
L"promptName", // eGameRuleAttr_promptName
@@ -85,24 +85,24 @@ WCHAR *GameRuleManager::wchAttrNameA[] =
GameRuleManager::GameRuleManager()
{
- m_currentGameRuleDefinitions = NULL;
- m_currentLevelGenerationOptions = NULL;
+ m_currentGameRuleDefinitions = nullptr;
+ m_currentLevelGenerationOptions = nullptr;
}
void GameRuleManager::loadGameRules(DLCPack *pack)
{
- StringTable *strings = NULL;
+ StringTable *strings = nullptr;
if(pack->doesPackContainFile(DLCManager::e_DLCType_LocalisationData,L"languages.loc"))
{
- DLCLocalisationFile *localisationFile = (DLCLocalisationFile *)pack->getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc");
+ DLCLocalisationFile *localisationFile = static_cast<DLCLocalisationFile *>(pack->getFile(DLCManager::e_DLCType_LocalisationData, L"languages.loc"));
strings = localisationFile->getStringTable();
}
int gameRulesCount = pack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader);
for(int i = 0; i < gameRulesCount; ++i)
{
- DLCGameRulesHeader *dlcHeader = (DLCGameRulesHeader *)pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i);
+ DLCGameRulesHeader *dlcHeader = static_cast<DLCGameRulesHeader *>(pack->getFile(DLCManager::e_DLCType_GameRulesHeader, i));
DWORD dSize;
byte *dData = dlcHeader->getData(dSize);
@@ -120,7 +120,7 @@ void GameRuleManager::loadGameRules(DLCPack *pack)
gameRulesCount = pack->getDLCItemsCount(DLCManager::e_DLCType_GameRules);
for (int i = 0; i < gameRulesCount; ++i)
{
- DLCGameRulesFile *dlcFile = (DLCGameRulesFile *)pack->getFile(DLCManager::e_DLCType_GameRules, i);
+ DLCGameRulesFile *dlcFile = static_cast<DLCGameRulesFile *>(pack->getFile(DLCManager::e_DLCType_GameRules, i));
DWORD dSize;
byte *dData = dlcFile->getData(dSize);
@@ -182,7 +182,7 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT
compr_content(new BYTE[compr_len], compr_len);
dis.read(compr_content);
- Compression::getCompression()->SetDecompressionType( (Compression::ECompressionTypes)compression_type );
+ Compression::getCompression()->SetDecompressionType( static_cast<Compression::ECompressionTypes>(compression_type) );
Compression::getCompression()->DecompressLZXRLE( content.data, &content.length,
compr_content.data, compr_content.length);
Compression::getCompression()->SetDecompressionType( SAVE_FILE_PLATFORM_LOCAL );
@@ -237,11 +237,11 @@ void GameRuleManager::loadGameRules(LevelGenerationOptions *lgo, byte *dIn, UINT
// 4J-JEV: Reverse of loadGameRules.
void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize)
{
- if (m_currentGameRuleDefinitions == NULL &&
- m_currentLevelGenerationOptions == NULL)
+ if (m_currentGameRuleDefinitions == nullptr &&
+ m_currentLevelGenerationOptions == nullptr)
{
app.DebugPrintf("GameRuleManager:: Nothing here to save.");
- *dOut = NULL;
+ *dOut = nullptr;
*dSize = 0;
return;
}
@@ -268,7 +268,7 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize)
ByteArrayOutputStream compr_baos;
DataOutputStream compr_dos(&compr_baos);
- if (m_currentGameRuleDefinitions == NULL)
+ if (m_currentGameRuleDefinitions == nullptr)
{
compr_dos.writeInt( 0 ); // numStrings for StringTable
compr_dos.writeInt( version_number );
@@ -282,9 +282,9 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize)
{
StringTable *st = m_currentGameRuleDefinitions->getStringTable();
- if (st == NULL)
+ if (st == nullptr)
{
- app.DebugPrintf("GameRuleManager::saveGameRules: StringTable == NULL!");
+ app.DebugPrintf("GameRuleManager::saveGameRules: StringTable == nullptr!");
}
else
{
@@ -322,7 +322,7 @@ void GameRuleManager::saveGameRules(byte **dOut, UINT *dSize)
*dSize = baos.buf.length;
*dOut = baos.buf.data;
- baos.buf.data = NULL;
+ baos.buf.data = nullptr;
dos.close(); baos.close();
}
@@ -344,6 +344,7 @@ void GameRuleManager::writeRuleFile(DataOutputStream *dos)
// Write schematic files.
unordered_map<wstring, ConsoleSchematicFile *> *files;
files = getLevelGenerationOptions()->getUnfinishedSchematicFiles();
+ dos->writeInt((int)files->size());
for ( auto& it : *files )
{
const wstring& filename = it.first;
@@ -385,7 +386,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)
{
@@ -399,8 +400,8 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT
for(int i = 0; i < 8; ++i) dis.readBoolean();
}
- ByteArrayInputStream *contentBais = NULL;
- DataInputStream *contentDis = NULL;
+ ByteArrayInputStream *contentBais = nullptr;
+ DataInputStream *contentDis = nullptr;
if(compressionType == Compression::eCompressionType_None)
{
@@ -469,13 +470,13 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT
tagsAndAtts.push_back( contentDis->readUTF() );
unordered_map<int, ConsoleGameRules::EGameRuleType> tagIdMap;
- for(int type = (int)ConsoleGameRules::eGameRuleType_Root; type < (int)ConsoleGameRules::eGameRuleType_Count; ++type)
+ for(int type = (int)ConsoleGameRules::eGameRuleType_Root; type < static_cast<int>(ConsoleGameRules::eGameRuleType_Count); ++type)
{
for(UINT i = 0; i < numStrings; ++i)
{
if(tagsAndAtts[i].compare(wchTagNameA[type]) == 0)
{
- tagIdMap.insert( unordered_map<int, ConsoleGameRules::EGameRuleType>::value_type(i, (ConsoleGameRules::EGameRuleType)type) );
+ tagIdMap.insert( unordered_map<int, ConsoleGameRules::EGameRuleType>::value_type(i, static_cast<ConsoleGameRules::EGameRuleType>(type)) );
break;
}
}
@@ -497,17 +498,36 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT
}*/
// subfile
+ // Old saves didn't write a numFiles count before the schematic entries.
+ // Detect this: a real count is small, but a UTF filename prefix reads as a large int.
UINT numFiles = contentDis->readInt();
- for (UINT i = 0; i < numFiles; i++)
- {
- wstring sFilename = contentDis->readUTF();
- int length = contentDis->readInt();
- byteArray ba( length );
-
- contentDis->read(ba);
-
- levelGenerator->loadSchematicFile(sFilename, ba.data, ba.length);
+ if (lgo->isFromSave() && numFiles > 100)
+ {
+ contentDis->skip(-4);
+ while (true)
+ {
+ int peek = contentDis->readInt();
+ if (peek <= 100) { contentDis->skip(-4); break; }
+ contentDis->skip(-4);
+
+ wstring sFilename = contentDis->readUTF();
+ int length = contentDis->readInt();
+ byteArray ba( length );
+ contentDis->read(ba);
+ levelGenerator->loadSchematicFile(sFilename, ba.data, ba.length);
+ }
+ }
+ else
+ {
+ for (UINT i = 0; i < numFiles; i++)
+ {
+ wstring sFilename = contentDis->readUTF();
+ int length = contentDis->readInt();
+ byteArray ba( length );
+ contentDis->read(ba);
+ levelGenerator->loadSchematicFile(sFilename, ba.data, ba.length);
+ }
}
LEVEL_GEN_ID lgoID = LEVEL_GEN_ID_NULL;
@@ -521,7 +541,7 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT
auto it = tagIdMap.find(tagId);
if(it != tagIdMap.end()) tagVal = it->second;
- GameRuleDefinition *rule = NULL;
+ GameRuleDefinition *rule = nullptr;
if(tagVal == ConsoleGameRules::eGameRuleType_LevelGenerationOptions)
{
@@ -548,14 +568,14 @@ bool GameRuleManager::readRuleFile(LevelGenerationOptions *lgo, byte *dIn, UINT
{
// Not default
contentDis->close();
- if(contentBais != NULL) delete contentBais;
+ if(contentBais != nullptr) delete contentBais;
delete contentDis;
}
dis.close();
bais.reset();
- //if(!levelGenAdded) { delete levelGenerator; levelGenerator = NULL; }
+ //if(!levelGenAdded) { delete levelGenerator; levelGenerator = nullptr; }
if(!gameRulesAdded) delete gameRules;
return true;
@@ -583,7 +603,7 @@ void GameRuleManager::readAttributes(DataInputStream *dis, vector<wstring> *tags
int attID = dis->readInt();
wstring value = dis->readUTF();
- if(rule != NULL) rule->addAttribute(tagsAndAtts->at(attID),value);
+ if(rule != nullptr) rule->addAttribute(tagsAndAtts->at(attID),value);
}
}
@@ -597,8 +617,8 @@ void GameRuleManager::readChildren(DataInputStream *dis, vector<wstring> *tagsAn
auto it = tagIdMap->find(tagId);
if(it != tagIdMap->end()) tagVal = it->second;
- GameRuleDefinition *childRule = NULL;
- if(rule != NULL) childRule = rule->addChild(tagVal);
+ GameRuleDefinition *childRule = nullptr;
+ if(rule != nullptr) childRule = rule->addChild(tagVal);
readAttributes(dis,tagsAndAtts,childRule);
readChildren(dis,tagsAndAtts,tagIdMap,childRule);
@@ -607,7 +627,7 @@ void GameRuleManager::readChildren(DataInputStream *dis, vector<wstring> *tagsAn
void GameRuleManager::processSchematics(LevelChunk *levelChunk)
{
- if(getLevelGenerationOptions() != NULL)
+ if(getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = getLevelGenerationOptions();
levelGenOptions->processSchematics(levelChunk);
@@ -616,7 +636,7 @@ void GameRuleManager::processSchematics(LevelChunk *levelChunk)
void GameRuleManager::processSchematicsLighting(LevelChunk *levelChunk)
{
- if(getLevelGenerationOptions() != NULL)
+ if(getLevelGenerationOptions() != nullptr)
{
LevelGenerationOptions *levelGenOptions = getLevelGenerationOptions();
levelGenOptions->processSchematicsLighting(levelChunk);
@@ -701,21 +721,21 @@ void GameRuleManager::setLevelGenerationOptions(LevelGenerationOptions *levelGen
{
unloadCurrentGameRules();
- m_currentGameRuleDefinitions = NULL;
+ m_currentGameRuleDefinitions = nullptr;
m_currentLevelGenerationOptions = levelGen;
- if(m_currentLevelGenerationOptions != NULL && m_currentLevelGenerationOptions->requiresGameRules() )
+ if(m_currentLevelGenerationOptions != nullptr && m_currentLevelGenerationOptions->requiresGameRules() )
{
m_currentGameRuleDefinitions = m_currentLevelGenerationOptions->getRequiredGameRules();
}
- if(m_currentLevelGenerationOptions != NULL)
+ if(m_currentLevelGenerationOptions != nullptr)
m_currentLevelGenerationOptions->reset_start();
}
LPCWSTR GameRuleManager::GetGameRulesString(const wstring &key)
{
- if(m_currentGameRuleDefinitions != NULL && !key.empty() )
+ if(m_currentGameRuleDefinitions != nullptr && !key.empty() )
{
return m_currentGameRuleDefinitions->getString(key);
}
@@ -739,9 +759,9 @@ LEVEL_GEN_ID GameRuleManager::addLevelGenerationOptions(LevelGenerationOptions *
void GameRuleManager::unloadCurrentGameRules()
{
- if (m_currentLevelGenerationOptions != NULL)
+ if (m_currentLevelGenerationOptions != nullptr)
{
- if (m_currentGameRuleDefinitions != NULL
+ if (m_currentGameRuleDefinitions != nullptr
&& m_currentLevelGenerationOptions->isFromSave())
m_levelRules.removeLevelRule( m_currentGameRuleDefinitions );
@@ -757,6 +777,6 @@ void GameRuleManager::unloadCurrentGameRules()
}
}
- m_currentGameRuleDefinitions = NULL;
- m_currentLevelGenerationOptions = NULL;
+ m_currentGameRuleDefinitions = nullptr;
+ m_currentLevelGenerationOptions = nullptr;
}
diff --git a/Minecraft.Client/Common/GameRules/GameRuleManager.h b/Minecraft.Client/Common/GameRules/GameRuleManager.h
index e9e983b8..3f446e84 100644
--- a/Minecraft.Client/Common/GameRules/GameRuleManager.h
+++ b/Minecraft.Client/Common/GameRules/GameRuleManager.h
@@ -24,8 +24,8 @@ class WstringLookup;
class GameRuleManager
{
public:
- static WCHAR *wchTagNameA[ConsoleGameRules::eGameRuleType_Count];
- static WCHAR *wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count];
+ static const WCHAR *wchTagNameA[ConsoleGameRules::eGameRuleType_Count];
+ static const WCHAR *wchAttrNameA[ConsoleGameRules::eGameRuleAttr_Count];
static const short version_number = 2;
diff --git a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp
index e49ee293..2af1826c 100644
--- a/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp
+++ b/Minecraft.Client/Common/GameRules/LevelGenerationOptions.cpp
@@ -44,8 +44,8 @@ bool JustGrSource::ready() { return true; }
LevelGenerationOptions::LevelGenerationOptions(DLCPack *parentPack)
{
- m_spawnPos = NULL;
- m_stringTable = NULL;
+ m_spawnPos = nullptr;
+ m_stringTable = nullptr;
m_hasLoadedData = false;
@@ -56,7 +56,7 @@ LevelGenerationOptions::LevelGenerationOptions(DLCPack *parentPack)
m_minY = INT_MAX;
m_bRequiresGameRules = false;
- m_pbBaseSaveData = NULL;
+ m_pbBaseSaveData = nullptr;
m_dwBaseSaveSize = 0;
m_parentDLCPack = parentPack;
@@ -66,7 +66,7 @@ LevelGenerationOptions::LevelGenerationOptions(DLCPack *parentPack)
LevelGenerationOptions::~LevelGenerationOptions()
{
clearSchematics();
- if(m_spawnPos != NULL) delete m_spawnPos;
+ if(m_spawnPos != nullptr) delete m_spawnPos;
for (auto& it : m_schematicRules )
{
delete it;
@@ -141,26 +141,26 @@ void LevelGenerationOptions::getChildren(vector<GameRuleDefinition *> *children)
GameRuleDefinition *LevelGenerationOptions::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
- GameRuleDefinition *rule = NULL;
+ GameRuleDefinition *rule = nullptr;
if(ruleType == ConsoleGameRules::eGameRuleType_ApplySchematic)
{
rule = new ApplySchematicRuleDefinition(this);
- m_schematicRules.push_back((ApplySchematicRuleDefinition *)rule);
+ m_schematicRules.push_back(static_cast<ApplySchematicRuleDefinition *>(rule));
}
else if(ruleType == ConsoleGameRules::eGameRuleType_GenerateStructure)
{
rule = new ConsoleGenerateStructure();
- m_structureRules.push_back((ConsoleGenerateStructure *)rule);
+ m_structureRules.push_back(static_cast<ConsoleGenerateStructure *>(rule));
}
else if(ruleType == ConsoleGameRules::eGameRuleType_BiomeOverride)
{
rule = new BiomeOverride();
- m_biomeOverrides.push_back((BiomeOverride *)rule);
+ m_biomeOverrides.push_back(static_cast<BiomeOverride *>(rule));
}
else if(ruleType == ConsoleGameRules::eGameRuleType_StartFeature)
{
rule = new StartFeature();
- m_features.push_back((StartFeature *)rule);
+ m_features.push_back(static_cast<StartFeature *>(rule));
}
else
{
@@ -175,26 +175,26 @@ void LevelGenerationOptions::addAttribute(const wstring &attributeName, const ws
{
if(attributeName.compare(L"seed") == 0)
{
- m_seed = _fromString<__int64>(attributeValue);
+ m_seed = _fromString<int64_t>(attributeValue);
app.DebugPrintf("LevelGenerationOptions: Adding parameter m_seed=%I64d\n",m_seed);
}
else if(attributeName.compare(L"spawnX") == 0)
{
- if(m_spawnPos == NULL) m_spawnPos = new Pos();
+ if(m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->x = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnX=%d\n",value);
}
else if(attributeName.compare(L"spawnY") == 0)
{
- if(m_spawnPos == NULL) m_spawnPos = new Pos();
+ if(m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->y = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnY=%d\n",value);
}
else if(attributeName.compare(L"spawnZ") == 0)
{
- if(m_spawnPos == NULL) m_spawnPos = new Pos();
+ if(m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->z = value;
app.DebugPrintf("LevelGenerationOptions: Adding parameter spawnZ=%d\n",value);
@@ -268,7 +268,7 @@ void LevelGenerationOptions::processSchematics(LevelChunk *chunk)
if (structureStart->getBoundingBox()->intersects(cx, cz, cx + 15, cz + 15))
{
BoundingBox *bb = new BoundingBox(cx, cz, cx + 15, cz + 15);
- structureStart->postProcess(chunk->level, NULL, bb);
+ structureStart->postProcess(chunk->level, nullptr, bb);
delete bb;
}
}
@@ -353,7 +353,7 @@ ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const wstring &f
return it->second;
}
- ConsoleSchematicFile *schematic = NULL;
+ ConsoleSchematicFile *schematic = nullptr;
byteArray data(pbData,dwLen);
ByteArrayInputStream bais(data);
DataInputStream dis(&bais);
@@ -366,7 +366,7 @@ ConsoleSchematicFile *LevelGenerationOptions::loadSchematicFile(const wstring &f
ConsoleSchematicFile *LevelGenerationOptions::getSchematicFile(const wstring &filename)
{
- ConsoleSchematicFile *schematic = NULL;
+ ConsoleSchematicFile *schematic = nullptr;
// If we have already loaded this, just return
auto it = m_schematics.find(filename);
if(it != m_schematics.end())
@@ -399,7 +399,7 @@ void LevelGenerationOptions::loadStringTable(StringTable *table)
LPCWSTR LevelGenerationOptions::getString(const wstring &key)
{
- if(m_stringTable == NULL)
+ if(m_stringTable == nullptr)
{
return L"";
}
@@ -455,8 +455,76 @@ unordered_map<wstring, ConsoleSchematicFile *> *LevelGenerationOptions::getUnfin
void LevelGenerationOptions::loadBaseSaveData()
{
+#ifdef _WINDOWS64
+
+ int gameRulesCount = m_parentDLCPack ? m_parentDLCPack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader) : 0;
+
+ wstring baseSave = getBaseSavePath();
+ wstring packName = baseSave.substr(0, baseSave.find(L'.'));
+
+ for (int i = 0; i < gameRulesCount; ++i)
+ {
+ DLCGameRulesHeader* dlcFile = static_cast<DLCGameRulesHeader*>(m_parentDLCPack->getFile(DLCManager::e_DLCType_GameRulesHeader, i));
+
+ if (!dlcFile->getGrfPath().empty())
+ {
+ File grf(L"Windows64Media\\DLC\\" + packName + L"\\Data\\" + dlcFile->getGrfPath());
+
+ if (grf.exists())
+ {
+ wstring path = grf.getPath();
+ HANDLE fileHandle = CreateFileW(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr);
+
+ if (fileHandle != INVALID_HANDLE_VALUE)
+ {
+ DWORD dwFileSize = grf.length();
+ DWORD bytesRead;
+ PBYTE pbData = new BYTE[dwFileSize];
+ BOOL bSuccess = ReadFile(fileHandle, pbData, dwFileSize, &bytesRead, nullptr);
+ CloseHandle(fileHandle);
+
+ if (bSuccess)
+ {
+ dlcFile->setGrfData(pbData, dwFileSize, m_stringTable);
+ app.m_gameRules.setLevelGenerationOptions(dlcFile->lgo);
+ }
+ delete[] pbData;
+ }
+ }
+ }
+ }
+
+ if (requiresBaseSave() && !getBaseSavePath().empty())
+ {
+ File save(L"Windows64Media\\DLC\\" + packName + L"\\Data\\" + baseSave);
+
+ if (save.exists())
+ {
+ wstring path = save.getPath();
+ HANDLE fileHandle = CreateFileW(path.c_str(), GENERIC_READ, 0, nullptr, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, nullptr);
+
+ if (fileHandle != INVALID_HANDLE_VALUE)
+ {
+ DWORD dwFileSize = GetFileSize(fileHandle, nullptr);
+ DWORD bytesRead;
+ PBYTE pbData = new BYTE[dwFileSize];
+ BOOL bSuccess = ReadFile(fileHandle, pbData, dwFileSize, &bytesRead, nullptr);
+ CloseHandle(fileHandle);
+
+ if (bSuccess)
+ setBaseSaveData(pbData, dwFileSize);
+ else
+ delete[] pbData;
+ }
+ }
+ }
+
+ setLoadedData();
+ app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_ReloadTexturePack);
+
+#else
int mountIndex = -1;
- if(m_parentDLCPack != NULL) mountIndex = m_parentDLCPack->GetDLCMountIndex();
+ if(m_parentDLCPack != nullptr) mountIndex = m_parentDLCPack->GetDLCMountIndex();
if(mountIndex > -1)
{
@@ -481,11 +549,12 @@ void LevelGenerationOptions::loadBaseSaveData()
setLoadedData();
app.SetAction(ProfileManager.GetPrimaryPad(), eAppAction_ReloadTexturePack);
}
+#endif
}
int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask)
{
- LevelGenerationOptions *lgo = (LevelGenerationOptions *)pParam;
+ LevelGenerationOptions *lgo = static_cast<LevelGenerationOptions *>(pParam);
lgo->m_bLoadingData = false;
if(dwErr!=ERROR_SUCCESS)
{
@@ -499,7 +568,7 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD
int gameRulesCount = lgo->m_parentDLCPack->getDLCItemsCount(DLCManager::e_DLCType_GameRulesHeader);
for(int i = 0; i < gameRulesCount; ++i)
{
- DLCGameRulesHeader *dlcFile = (DLCGameRulesHeader *) lgo->m_parentDLCPack->getFile(DLCManager::e_DLCType_GameRulesHeader, i);
+ DLCGameRulesHeader *dlcFile = static_cast<DLCGameRulesHeader *>(lgo->m_parentDLCPack->getFile(DLCManager::e_DLCType_GameRulesHeader, i));
if (!dlcFile->getGrfPath().empty())
{
@@ -513,10 +582,10 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD
pchFilename, // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
- NULL, // Unused
+ nullptr, // Unused
OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
- NULL // Unsupported
+ nullptr // Unsupported
);
#else
const char *pchFilename=wstringtofilename(grf.getPath());
@@ -524,10 +593,10 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD
pchFilename, // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
- NULL, // Unused
+ nullptr, // Unused
OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
- NULL // Unsupported
+ nullptr // Unsupported
);
#endif
@@ -536,7 +605,7 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD
DWORD dwFileSize = grf.length();
DWORD bytesRead;
PBYTE pbData = (PBYTE) new BYTE[dwFileSize];
- BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL);
+ BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,nullptr);
if(bSuccess==FALSE)
{
app.FatalLoadError();
@@ -565,10 +634,10 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD
pchFilename, // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
- NULL, // Unused
+ nullptr, // Unused
OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
- NULL // Unsupported
+ nullptr // Unsupported
);
#else
const char *pchFilename=wstringtofilename(save.getPath());
@@ -576,18 +645,18 @@ int LevelGenerationOptions::packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD
pchFilename, // file name
GENERIC_READ, // access mode
0, // share mode // TODO 4J Stu - Will we need to share file? Probably not but...
- NULL, // Unused
+ nullptr, // Unused
OPEN_EXISTING , // how to create // TODO 4J Stu - Assuming that the file already exists if we are opening to read from it
FILE_FLAG_SEQUENTIAL_SCAN, // file attributes
- NULL // Unsupported
+ nullptr // Unsupported
);
#endif
if( fileHandle != INVALID_HANDLE_VALUE )
{
- DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,NULL);
+ DWORD bytesRead,dwFileSize = GetFileSize(fileHandle,nullptr);
PBYTE pbData = (PBYTE) new BYTE[dwFileSize];
- BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,NULL);
+ BOOL bSuccess = ReadFile(fileHandle,pbData,dwFileSize,&bytesRead,nullptr);
if(bSuccess==FALSE)
{
app.FatalLoadError();
@@ -624,8 +693,8 @@ void LevelGenerationOptions::reset_start()
void LevelGenerationOptions::reset_finish()
{
- //if (m_spawnPos) { delete m_spawnPos; m_spawnPos = NULL; }
- //if (m_stringTable) { delete m_stringTable; m_stringTable = NULL; }
+ //if (m_spawnPos) { delete m_spawnPos; m_spawnPos = nullptr; }
+ //if (m_stringTable) { delete m_stringTable; m_stringTable = nullptr; }
if (isFromDLC())
{
@@ -694,13 +763,13 @@ bool LevelGenerationOptions::ready() { return info()->ready(); }
void LevelGenerationOptions::setBaseSaveData(PBYTE pbData, DWORD dwSize) { m_pbBaseSaveData = pbData; m_dwBaseSaveSize = dwSize; }
PBYTE LevelGenerationOptions::getBaseSaveData(DWORD &size) { size = m_dwBaseSaveSize; return m_pbBaseSaveData; }
-bool LevelGenerationOptions::hasBaseSaveData() { return m_dwBaseSaveSize > 0 && m_pbBaseSaveData != NULL; }
-void LevelGenerationOptions::deleteBaseSaveData() { if(m_pbBaseSaveData) delete m_pbBaseSaveData; m_pbBaseSaveData = NULL; m_dwBaseSaveSize = 0; }
+bool LevelGenerationOptions::hasBaseSaveData() { return m_dwBaseSaveSize > 0 && m_pbBaseSaveData != nullptr; }
+void LevelGenerationOptions::deleteBaseSaveData() { if(m_pbBaseSaveData) delete m_pbBaseSaveData; m_pbBaseSaveData = nullptr; m_dwBaseSaveSize = 0; }
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; }
int LevelGenerationOptions::getLevelHasBeenInCreative() { return m_bHasBeenInCreative; }
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 aa128ff8..378ac6c5 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;
int m_bHasBeenInCreative;
@@ -167,17 +167,17 @@ private:
bool m_bLoadingData;
public:
- LevelGenerationOptions(DLCPack *parentPack = NULL);
+ LevelGenerationOptions(DLCPack *parentPack = nullptr);
~LevelGenerationOptions();
virtual ConsoleGameRules::EGameRuleType getActionType();
-
+
virtual void writeAttributes(DataOutputStream *dos, UINT numAttributes);
virtual void getChildren(vector<GameRuleDefinition *> *children);
virtual GameRuleDefinition *addChild(ConsoleGameRules::EGameRuleType ruleType);
virtual void addAttribute(const wstring &attributeName, const wstring &attributeValue);
- __int64 getLevelSeed();
+ int64_t getLevelSeed();
int getLevelHasBeenInCreative();
Pos *getSpawnPos();
bool getuseFlatWorld();
@@ -190,7 +190,7 @@ public:
private:
void clearSchematics();
-public:
+public:
ConsoleSchematicFile *loadSchematicFile(const wstring &filename, PBYTE pbData, DWORD dwLen);
public:
@@ -202,7 +202,7 @@ public:
LevelRuleset *getRequiredGameRules();
void getBiomeOverride(int biomeId, BYTE &tile, BYTE &topTile);
- bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature, int *orientation = NULL);
+ bool isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature, int *orientation = nullptr);
void loadStringTable(StringTable *table);
LPCWSTR getString(const wstring &key);
@@ -211,7 +211,7 @@ public:
void loadBaseSaveData();
static int packMounted(LPVOID pParam,int iPad,DWORD dwErr,DWORD dwLicenceMask);
-
+
// 4J-JEV:
// ApplySchematicRules contain limited state
// which needs to be reset BEFORE a new game starts.
diff --git a/Minecraft.Client/Common/GameRules/LevelRuleset.cpp b/Minecraft.Client/Common/GameRules/LevelRuleset.cpp
index 658abe91..de17bacc 100644
--- a/Minecraft.Client/Common/GameRules/LevelRuleset.cpp
+++ b/Minecraft.Client/Common/GameRules/LevelRuleset.cpp
@@ -6,7 +6,7 @@
LevelRuleset::LevelRuleset()
{
- m_stringTable = NULL;
+ m_stringTable = nullptr;
}
LevelRuleset::~LevelRuleset()
@@ -26,11 +26,11 @@ void LevelRuleset::getChildren(vector<GameRuleDefinition *> *children)
GameRuleDefinition *LevelRuleset::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
- GameRuleDefinition *rule = NULL;
+ GameRuleDefinition *rule = nullptr;
if(ruleType == ConsoleGameRules::eGameRuleType_NamedArea)
{
rule = new NamedAreaRuleDefinition();
- m_areas.push_back((NamedAreaRuleDefinition *)rule);
+ m_areas.push_back(static_cast<NamedAreaRuleDefinition *>(rule));
}
else
{
@@ -46,7 +46,7 @@ void LevelRuleset::loadStringTable(StringTable *table)
LPCWSTR LevelRuleset::getString(const wstring &key)
{
- if(m_stringTable == NULL)
+ if(m_stringTable == nullptr)
{
return L"";
}
diff --git a/Minecraft.Client/Common/GameRules/StartFeature.cpp b/Minecraft.Client/Common/GameRules/StartFeature.cpp
index 904bce73..14b6d9c9 100644
--- a/Minecraft.Client/Common/GameRules/StartFeature.cpp
+++ b/Minecraft.Client/Common/GameRules/StartFeature.cpp
@@ -47,7 +47,7 @@ void StartFeature::addAttribute(const wstring &attributeName, const wstring &att
else if(attributeName.compare(L"feature") == 0)
{
int value = _fromString<int>(attributeValue);
- m_feature = (StructureFeature::EFeatureTypes)value;
+ m_feature = static_cast<StructureFeature::EFeatureTypes>(value);
app.DebugPrintf("StartFeature: Adding parameter feature=%d\n",m_feature);
}
else
@@ -58,6 +58,6 @@ void StartFeature::addAttribute(const wstring &attributeName, const wstring &att
bool StartFeature::isFeatureChunk(int chunkX, int chunkZ, StructureFeature::EFeatureTypes feature, int *orientation)
{
- if(orientation != NULL) *orientation = m_orientation;
+ if(orientation != nullptr) *orientation = m_orientation;
return chunkX == m_chunkX && chunkZ == m_chunkZ && feature == m_feature;
} \ No newline at end of file
diff --git a/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp b/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp
index ec218c7a..99aee99b 100644
--- a/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp
+++ b/Minecraft.Client/Common/GameRules/UpdatePlayerRuleDefinition.cpp
@@ -12,7 +12,7 @@ UpdatePlayerRuleDefinition::UpdatePlayerRuleDefinition()
m_bUpdateHealth = m_bUpdateFood = m_bUpdateYRot = false;;
m_health = 0;
m_food = 0;
- m_spawnPos = NULL;
+ m_spawnPos = nullptr;
m_yRot = 0.0f;
}
@@ -65,11 +65,11 @@ void UpdatePlayerRuleDefinition::getChildren(vector<GameRuleDefinition *> *child
GameRuleDefinition *UpdatePlayerRuleDefinition::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
- GameRuleDefinition *rule = NULL;
+ GameRuleDefinition *rule = nullptr;
if(ruleType == ConsoleGameRules::eGameRuleType_AddItem)
{
rule = new AddItemRuleDefinition();
- m_items.push_back((AddItemRuleDefinition *)rule);
+ m_items.push_back(static_cast<AddItemRuleDefinition *>(rule));
}
else
{
@@ -84,21 +84,21 @@ void UpdatePlayerRuleDefinition::addAttribute(const wstring &attributeName, cons
{
if(attributeName.compare(L"spawnX") == 0)
{
- if(m_spawnPos == NULL) m_spawnPos = new Pos();
+ if(m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->x = value;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnX=%d\n",value);
}
else if(attributeName.compare(L"spawnY") == 0)
{
- if(m_spawnPos == NULL) m_spawnPos = new Pos();
+ if(m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->y = value;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnY=%d\n",value);
}
else if(attributeName.compare(L"spawnZ") == 0)
{
- if(m_spawnPos == NULL) m_spawnPos = new Pos();
+ if(m_spawnPos == nullptr) m_spawnPos = new Pos();
int value = _fromString<int>(attributeValue);
m_spawnPos->z = value;
app.DebugPrintf("UpdatePlayerRuleDefinition: Adding parameter spawnZ=%d\n",value);
@@ -148,7 +148,7 @@ void UpdatePlayerRuleDefinition::postProcessPlayer(shared_ptr<Player> player)
double z = player->z;
float yRot = player->yRot;
float xRot = player->xRot;
- if(m_spawnPos != NULL)
+ if(m_spawnPos != nullptr)
{
x = m_spawnPos->x;
y = m_spawnPos->y;
@@ -160,7 +160,7 @@ void UpdatePlayerRuleDefinition::postProcessPlayer(shared_ptr<Player> player)
yRot = m_yRot;
}
- if(m_spawnPos != NULL || m_bUpdateYRot) player->absMoveTo(x,y,z,yRot,xRot);
+ if(m_spawnPos != nullptr || m_bUpdateYRot) player->absMoveTo(x,y,z,yRot,xRot);
for(auto& addItem : m_items)
{
diff --git a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp
index fa68ef6a..1f494691 100644
--- a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp
+++ b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceContainer.cpp
@@ -33,11 +33,11 @@ void XboxStructureActionPlaceContainer::getChildren(vector<GameRuleDefinition *>
GameRuleDefinition *XboxStructureActionPlaceContainer::addChild(ConsoleGameRules::EGameRuleType ruleType)
{
- GameRuleDefinition *rule = NULL;
+ GameRuleDefinition *rule = nullptr;
if(ruleType == ConsoleGameRules::eGameRuleType_AddItem)
{
rule = new AddItemRuleDefinition();
- m_items.push_back((AddItemRuleDefinition *)rule);
+ m_items.push_back(static_cast<AddItemRuleDefinition *>(rule));
}
else
{
@@ -70,7 +70,7 @@ bool XboxStructureActionPlaceContainer::placeContainerInLevel(StructurePiece *st
if ( chunkBB->isInside( worldX, worldY, worldZ ) )
{
- if ( level->getTileEntity( worldX, worldY, worldZ ) != NULL )
+ if ( level->getTileEntity( worldX, worldY, worldZ ) != nullptr )
{
// Remove the current tile entity
level->removeTileEntity( worldX, worldY, worldZ );
@@ -81,7 +81,7 @@ bool XboxStructureActionPlaceContainer::placeContainerInLevel(StructurePiece *st
shared_ptr<Container> container = dynamic_pointer_cast<Container>(level->getTileEntity( worldX, worldY, worldZ ));
app.DebugPrintf("XboxStructureActionPlaceContainer - placing a container at (%d,%d,%d)\n", worldX, worldY, worldZ);
- if ( container != NULL )
+ if ( container != nullptr )
{
level->setData( worldX, worldY, worldZ, m_data, Tile::UPDATE_CLIENTS);
// Add items
diff --git a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp
index 3f6204af..3e61154f 100644
--- a/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp
+++ b/Minecraft.Client/Common/GameRules/XboxStructureActionPlaceSpawner.cpp
@@ -46,7 +46,7 @@ bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel(StructurePiece *struct
if ( chunkBB->isInside( worldX, worldY, worldZ ) )
{
- if ( level->getTileEntity( worldX, worldY, worldZ ) != NULL )
+ if ( level->getTileEntity( worldX, worldY, worldZ ) != nullptr )
{
// Remove the current tile entity
level->removeTileEntity( worldX, worldY, worldZ );
@@ -59,7 +59,7 @@ bool XboxStructureActionPlaceSpawner::placeSpawnerInLevel(StructurePiece *struct
#ifndef _CONTENT_PACKAGE
wprintf(L"XboxStructureActionPlaceSpawner - placing a %ls spawner at (%d,%d,%d)\n", m_entityId.c_str(), worldX, worldY, worldZ);
#endif
- if( entity != NULL )
+ if( entity != nullptr )
{
entity->setEntityId(m_entityId);
}